修改mysql的表結構

2021-04-13 12:04:42 字數 608 閱讀 8990

修改字段屬性

alter table tablename modify id int(10) unsigned auto_increment primary key not null

修改預設值

alter table tablename alter id default 0

給字段增加primary key

alter table tablename add primary key(id);

刪除primary key

1、alter table tablename drop primary key;

2、drop primary key on tablename;

檢視table表結構

show create table tablename;

修改table表資料引擎

alter table tablename engine = myisam (innodb);

增加字段

alter table `table` add `field` int(11) unsigned not null

刪除字段

alert table 'table' drop 'field'

mysql 修改表結構

1.mysql 修改表名字 alter table t1 rename t2 2.修改列的名字 alter table stock change column stock id id int 6 3.增加列 alter table ab add column id int 3 4.減少列 alter...

MySql表結構修改

1 在表的最後追加一列 語法 alter table 表名 add 列名 列型別 列引數 例如 alter table test add name char 30 not null default tom 2 在某列後面加一列 語法 alter table 表名 add 列名 列型別 列引數 aft...

Mysql表結構修改

修改場景 建立了乙個表但是忘記把主鍵設定為自增長 create table work info work id int 11 not null,company varchar 64 default null,position varchar 32 default null,duty varchar ...