您好,欢迎访问一九零五行业门户网

给MySQL表增加指定位置的列_MySQL

alter table test add column id int unsigned not null auto_increment primary key first给表添加列是一个常用的操作,mysql增加列的时候可以指定此列的位置给指定位置加列需要两个关键字:first和afterfirst表示增加此列为第一个列after表示增加在某个列之后注意mysql增加列指定位置时没有before的用法,第一列可以使用first,非第一列使用after。语法:
alter table table_name add [column] col_name column_definition [ first | after col_name]
实例:drop table if exists `test`;create table `test` ( `a` int(11) not null, `b` varchar(200) not null) engine=innodb default charset=utf8;
在test表a列后面增加一列c:alter table test add column c int not null after a
在test表的第一列增加字段id:alter table test add column id int unsigned not null auto_increment primary key first
全文完。
其它类似信息

推荐信息