1. 程式人生 > >給已有表新增自增長主鍵 id

給已有表新增自增長主鍵 id

在給已有表新增自增長主鍵id 時需要用如下

 ALTER TABLE test_lcm_ ADD COLUMN lcm_id int(11)  NOT NULL AUTO_INCREMENT,ADD primary KEY(lcm_id);

注意: 一個表中,最多隻能有一個自動欄位,並且這個自動欄位還必須被定義為key。

或者下列也可以 

alter table `base_dictmark` add dict_id int not null primary key Auto_increment  first;