such as table: User
Field: UserID name PW
The Useid of the user table is not self increasing. We changed the UserID to a self increase.
Execute the following statement to increase the UserID by 1 each time.
Statement: ALTER TABLE ' user ' change userid userid int is not NULL auto_increment primary key;
SQL of table:
CREATE TABLE ' user ' (
' username ' varchar not NULL,
' PW ' varchar not NULL,
' userid ' int (one) not NULL auto_increment,
PRIMARY KEY (' userid ')
) Engine=innodb DEFAULT Charset=utf8;
Extend Knowledge://Add field and set Primary key ALTER TABLE tabelname add new_field_id int (5) unsigned default 0 NOT NULL auto_increment, add prima Ry Key (new_field_id); The index ALTER TABLE tablename Add primary key (ID) of the primary keyword; Gazzo Primer www.2cto.com ALTER TABLE tablename change depno depno int (5) is not null; ALTER TABLE tablename ADD index index name (field name 1[, field Name 2 ...]); ALTER TABLE tablename ADD INDEX emp_name (name); Index ALTER TABLE tablename add unique emp_name2 (Cardnumber) with unique restriction criteria; Deletes an index ALTER TABLE tablename DROP index emp_name; Add field: ALTER TABLE table_name add field_name field_type; Delete field ALTER TABLE table_name DROP field_name; Rename column ALTER TABLE table_name change field_name1 field_name2 integer; Adjust field order ALTER TABLE ' users ' change ' user_password ' user_password ' varchar ' isn't NULL after user_name; Alter the type of the column ALTER TABLE table_name change field_name 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 Table 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) PRIMARY key not NULL, M Ail_filename varchar (), content varchar) 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 varchar () not null,content varchar (?), INDEX (RID), FOREIGN KEY (RID) REFERENCES Mail_model (ID) on DELETE CASCADE on Up DATE CASCADE) Engine=innodb DEFAULT CHARSET=GBK;