How should MySQL add fields be implemented? This is a lot of new contacts MySQL database has been mentioned, the following is to introduce you to MySQL add fields and delete the field method, I hope you can be enlightened.
MySQL add field:
ALTER TABLE ' User_movement_log ' add column Gatewayid int not null default 0 after ' RegionID ' (which field is added later)
To delete a field:
ALTER TABLE ' user_movement_log ' drop column Gatewayid
To adjust the order of fields:
alter table ' User_movement_log ' CHANGE ' Gatewayid ' ' Gatewayid ' int not null default 0 after regionid //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 a new column alter table t2 add d timestamp; alter table infos add ex tinyint not null default ' 0 ';//Delete Column alter table t2 drop column c;//Renaming Columns alter table t1 change a b integer; //changing the type of column alter table t1 change b b bigint not null; alter table infos change list list tinyint not null default ' 0 '; //renaming tables alter table t1 rename t2;//Gazzo citation mysql> alter table tablename change depno depno int (5) not null; mysql> alter table tablename add index Index name (field name 1[, field name 2 ...]); mysql> alter table tablename add index emp_name (name);// Index mysql> alter table tablename add primary key (ID) of the main keyword;// Index mysql> alter table tablename add unique emp_name2 with unique restriction conditions (cardnumber);//delete an index mysql>alter table tablename drop index emp_ Name
Add Field:
MySQL Add, delete fields, adjust fields