您的位置:首页 > 数据库 > MySQL

mysql在表的某一位置增加一列、删除一列、修改列名

2013-10-10 19:32 381 查看
如果想在一个已经建好的表中添加一列,可以用诸如:

alter table t1 add column addr varchar(20) not null;

这条语句会向已有的表t1中加入一列addr,这一列在表的最后一列位置。如果我们希望添加在指定的一列,可以用:

alter table t1 add column addr varchar(20) not null after user1;

注意,上面这个命令的意思是说添加addr列到user1这一列后面。如果想添加到第一列的话,可以用:

alter table t1 add column addr varchar(20) not null first;

将表web1.new_table change中,列名def改为unit

alter table web1.new_table change def unit char;

将表web1.new_table change中,列名def的列删除

alter table web1.new_table drop column def ;

转自:http://blog.csdn.net/qiuchangyong/article/details/7246242
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: