alter add命令用来增加表的字段。 alter add命令格式:alter table 表名 add字段 类型 其他;
mysql> alter table MyTable add TEST int(4) default '0';//在表MyTable中添加了一个字段TEST,类型为int(4),默认值为0: mysql> alter table table1 add transactor varchar(10) not Null; mysql> alter table table1 add id int unsigned not Null auto_increment primary key例子:
mysql> alter table employee add index emp_name (name); mysql> alter table table1 add transactor varchar(10) not Null; mysql> alter table table1 add id int unsigned not Null auto_increment primary key例子:
mysql> alter table employee add primary key(id);例子:
mysql> alter table employee add unique emp_name2(cardnumber);例子:
mysql> alter table employee drop index emp_name;