美文网首页
mysql在表的某一位置增加一列、删除一列、修改列名

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

作者: 明月888 | 来源:发表于2018-01-09 14:42 被阅读0次

如果想在一个已经建好的表中添加一列,可以用诸如:

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

相关文章

网友评论

      本文标题:mysql在表的某一位置增加一列、删除一列、修改列名

      本文链接:https://www.haomeiwen.com/subject/ggownxtx.html