Mysql modifies the ID attribute of an existing table to auto_increment for automatic growth. Today, you need to set the automatic growth attribute of an existing table as follows: alter table customers change id int not null auto_increment primary key; extended knowledge: // ADD a field and set the primary key alter table tabelname ADD new_field_id int (5) unsigned default 0 not null auto_increment, ADD primary key (new_field_id ); // ADD the index alter table tablename ADD primary key (id); // ADD the index www.2cto.com alter table tablename CHANGE depno int (5) not null; Alter table tablename add index name (field name 1 [, field name 2…]); Alter table tablename add index emp_name (name); // ADD the index alter table tablename add unique emp_name2 (cardnumber) with UNIQUE restrictions; // delete an index alter table tablename drop index emp_name; // ADD a field: alter table table_name ADD field_name field_type; // Delete the field alter table table_name DROP field_name; // rename the alter table table_name CHANGE field_name1 field_name2 integer; // adjust the field order alter table 'users' CHANGE 'user _ password' varchar (20) not null after user_name; // alter table table_name CHANGE field_name bigint not null; alter table infos CHANGE list tinyint not null default '0'; // modify the original field name and type: www.2cto.com alter table table_name CHANGE old_field_name new_field_name field_type; // rename the alter table table_name rename new_table_name; // cascade update and delete (red, Case Insensitive) drop table if exists 'mail _ model'; create TABLE mail_model (id varchar (50) primary key not null, mail_filename varchar (200), content varchar (2000 )) ENGINE = InnoDB default charset = gbk; drop table if exists 'mail _ model_extend '; create TABLE mail_model_extend (id int (6) auto_increment not null primary key, rid varchar (50) not null, content varchar (2000), INDEX (RID), foreign key (RID) REFERENCES mail_model (ID) on delete cascade on update cascade) ENGINE = InnoDB default charset = gbk; author: DouglasLau