¼Ó×ֶΡ¢É¾³ý×ֶΡ¢µ÷Õû×Ö¶Î˳Ðò
ÎÄÕ·ÖÀà:Êý¾Ý¿â
Sql´úÂë
ALTER TABLE — ¸ü¸Ä±íÊôÐÔ
Ìí¼Ó×ֶΣº
alter table `user_movement_log`
Add column GatewayId int not null default 0 AFTER `Regionid` (ÔÚÄĸö×ֶκóÃæÌí¼Ó)
ɾ³ý×ֶΣº
alter table `user_movement_log` drop column Gatewayid
µ÷Õû×Ö¶Î˳Ðò£º
ALTER TABLE `user_movement_log` CHANGE `GatewayId` `GatewayId` int not null default 0 AFTER RegionID
mysql alter Óï¾äÓ÷¨,Ìí¼Ó¡¢Ð޸ġ¢É¾³ý×ֶεÈ
//Ö÷¼ü549830479
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//Ôö¼ÓÒ»¸öÐÂÁÐ549830479
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
//ɾ³ýÁÐ549830479
alter table t2 drop column c;
//ÖØÃüÃûÁÐ549830479
alter table t1 change a b integer;
//¸Ä±äÁеÄÀàÐÍ549830479
alter table t1 change b b bigint not null;
alter table infos change list list tinyint not null default '0';
//ÖØÃüÃû±í549830479
alter table t1 rename t2;
¼ÓË÷Òý549830479
mysql> alter table tablename change depno depno int(5) not null;
mysql> alter table tablename add index Ë÷ÒýÃû (×Ö¶ÎÃû1[£¬×Ö¶ÎÃû2 …]);
mysql> alter table tablename add index emp_name (name);
¼ÓÖ÷¹Ø¼ü×ÖµÄË÷Òý549830479
mysql> alter table tablename add primary key(id);
¼ÓΨһÏÞÖÆÌõ¼þµÄË÷Òý549830479
mysql> alter table tablename add unique emp_name2(cardnumber);
ɾ³ýij¸öË÷Òý549830479
mysql>alter table tablename drop index emp_name;
ÐÞ¸Ä±í£º549830479
Ôö¼Ó×ֶΣº549830479
mysql> ALTER TABLE table_name ADD field_name field_type;
ÐÞ¸ÄÔ×Ö¶ÎÃû³Æ¼°ÀàÐÍ£º549830479
mysql> ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;
ɾ³ý×ֶΣº549830479
mysql> ALTER TABLE table_name DROP field_name;
[/img]..