ä¸é¢ååºï¼
1.å¢å ä¸ä¸ªå段
alter table user add COLUMN new1 VARCHAR(20) DEFAULT NULL; //å¢å ä¸ä¸ªå段ï¼é»è®¤ä¸ºç©º
alter table user add COLUMN new2 VARCHAR(20) NOT NULL; ãã //å¢å ä¸ä¸ªå段ï¼é»è®¤ä¸è½ä¸ºç©º
2.å é¤ä¸ä¸ªå段
alter table user DROP COLUMN new2; ãããããããããããããã //å é¤ä¸ä¸ªå段
3.ä¿®æ¹ä¸ä¸ªå段
alter table user MODIFY new1 VARCHAR(10); ãããããããããã //ä¿®æ¹ä¸ä¸ªå段çç±»å
alter table user CHANGE new1 new4 int;ããããããããããããã //ä¿®æ¹ä¸ä¸ªå段çå称ï¼æ¤æ¶ä¸å®è¦éæ°
//主é®
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//å¢å ä¸ä¸ªæ°å
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default â0â²;
//å é¤å
alter table t2 drop column c;
//éå½åå
alter table t1 change a b integer;
//æ¹ååçç±»å
alter table t1 change b b bigint not null;
alter table infos change list list tinyint not null default â0â²;
//éå½å表
alter table t1 rename t2;
å ç´¢å¼
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);
å 主å
³é®åçç´¢å¼
mysql> alter table tablename add primary key(id);
å å¯ä¸éå¶æ¡ä»¶çç´¢å¼
mysql> alter table tablename add unique emp_name2(cardnumber);
å é¤æ个索å¼
mysql>alter table tablename drop index emp_name;
å¢å å段ï¼
mysql> ALTER TABLE table_name ADD field_name field_type;
ä¿®æ¹åå段å称åç±»åï¼
mysql> ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;
å é¤å段ï¼
mysql> ALTER TABLE table_name DROP field_name;
mysqlä¿®æ¹å段é¿åº¦
alter table 表å modify column å段å ç±»å;
ä¾å¦
æ°æ®åºä¸user表 nameå段æ¯varchar(30)
å¯ä»¥ç¨
alter table user modify column name varchar(50) ;
温馨提示:答案为网友推荐,仅供参考