Add a field to a table ALTER TABLE name the type of the Add Field name fields
Example: ALTER TABLE table1 add transactor varchar (ten) not Null;
ALTER TABLE table1 add ID int unsigned not Null auto_increment primary key
How to add a field after a specified field in the MySQL database:
ALTER TABLE Newexample add address varchar (a) after stu_id;
Modifying the field type of a table ALTER table name MODIFY COLUMN field type definition;
Example: ALTER TABLE chatter_users MODIFY COLUMN IP VARCHAR (50);
Modify the field name of the table ALTER TABLE name change the original field name the type of the new field name segment
example: ALTER TABLE student change Physics Physisc char (TEN) NOT NULL
Delete a table field ALTER TABLE name drop column field name
Example: Alter TABLE ' user_movement_log ' drop column Gatewayid
Adjust table order: ALTER table ' user_movement_log ' change ' Gatewayid ' gatewayid ' int not null default 0 after RegionID
table rename ALTER TABLE name rename present table name;
Example: ALTER TABLE t1 rename T2;
Delete table data Delete from table name where (condition) ID is not starting from 1, TRUNCATE table name ID is starting from 1
Example of creating a table
CREATE TABLE hlh_message (
ID Int (one) not NULL auto_increment COMMENT ' health table ID ',
Title varchar (+) not NULL COMMENT ' health title ',
Hlh_url text DEFAULT NULL COMMENT ' picture address ',
BeWrite VARCHAR () not NULL COMMENT ' description ',
Content VARCHAR (+) not NULL COMMENT ' contents ',
Type tinyint (1) Not NULL DEFAULT ' 0 ' COMMENT ' health Knowledge 0 Health Consulting 1 ',
Create_time date DEFAULT NULL COMMENT ' time to publish message ',
PRIMARY KEY (ID)
) Engine=innodb DEFAULT Charset=utf8 comment= ' health table '
MySQL Modify Add Delete table field