mysql 表的常见操作_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
2
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 1725 | 回复: 1   主题: mysql 表的常见操作        下一篇 
xiaojiang
注册用户
等级:少尉
经验:345
发帖:77
精华:0
注册:2011-8-31
状态:离线
发送短消息息给xiaojiang 加好友    发送短消息息给xiaojiang 发消息
发表于: IP:您无权察看 2015-6-19 14:11:17 | [全部帖] [楼主帖] 楼主

取消列的自增长:

alter table cust_consume change cid cid int;


设置自增长列:

alter table cust_consume
modify `cid` int(11) auto_increment;


设置自增列的起始值:

alter table cust_consume auto_increment=10;


为表添加备注:
alter table cust_consume comment '自动分配表'

修改表的字符集

alter table temp04 CHARSET=utf8
-- 添加字段并将字段设置为主键 ,设置为第一列
alter table  tabelname
add   conlumn_name  data_type default 0 not null auto_increment  First,
add   primary key (new_field_id);


例子:

alter table  temp01
add   eid  int   not null auto_increment ,
add   primary key (eid);
-- 在某个字段后面添加一列
alter table  tabelname
add   conlumn_name  data_type default 0 after column_name1,
-- 修改字段名
alter table tablename
change   old_column_name    new_column_name  oldType;


例子:

alter table temp01
change   gameAccount   Account  varchar(100);


这个oldType 不一定是老的数据类型,只要是一个兼容的数据类型就行,但是为了
保证数据的正确性(数据截断) ,最好给定老的数据类型

--修改字段类型 
alter table  tablename
change   filed_name  filed_name  new_type;


例子:

alter table   temp01
change  gameAccount  gameAccount   char(100);


--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
superstar
注册用户
等级:上尉
经验:525
发帖:2
精华:0
注册:2015-6-3
状态:离线
发送短消息息给superstar 加好友    发送短消息息给superstar 发消息
发表于: IP:您无权察看 2015-6-19 14:13:49 | [全部帖] [楼主帖] 2  楼

add   conlumn_name  data_type default 0 after column_name1这条收藏了


赞(0)    操作        顶端 
总帖数
2
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论