Self-summary, there is any need to correct the supplementary place, please correct me, thank you!
Purpose: When the table structure needs to be modified in the project and it needs to be advertised to other colleagues, the efficient way to do this is to send the statement that modifies the table structure to other colleagues.
Operations on table fields: Add,drop,modify | Change.
add: Feature 1: New Add field (default Add New field after all fields) syntax 1:alter table+ Table name + add + new Field + new field type + whether new field can be empty +default ALTER TABLE student add classname varchar (() notNULL default‘‘; function 2: Place the new plus field at the front of all fields syntax: ALTER TABLE+ table name +add + new field + new field type + new field is empty + default value +First ALTER TABLE student add classname varchar (() notNULL default‘‘function 3: Break the current price again after a field syntax: ALTER TABLE+ table name +add + new field + new field type + new field is empty + default + after +the field name that already exists ALTER TABLE student add ClassnointNotNULLAfter age ; drop: syntax: ALTER TABLE+ Table name +drop +the field name that already exists ALTER TABLE student drop classno; Modify table Field properties: function 1 (Modify): Modify the type or default syntax for fields: ALTER TABLE+ Table name +modify + fields to modify + Modify field type +default ALTER TABLE student modify name varchar (() notNULL default‘‘; function 2 (change): Modify the name of the field syntax: ALTER TABLE+ table name +change + Old field + new Field + new type + null +default ALTER TABLE student change name room_id varchar (6) notNULL default' 0 ';
Basic information:
1. The Modify Table Structure command is identified with an [ALTER] statement, for example [ALTER TABLE student] 2. Add,Modify, and delete command identifiers for Add, modify, drop, respectively. 3. View table structure statements for example [DESC student;] 4. View the build table statements such as [ Show create table student;] 5. Setting default values is not required, and if you do, the default value for MySQL is null 6. Not NULL is not required, and if you do, the default value for MySQL is yes to default 0 is the same Of
I also refer to other friends of the park blog,
Original source: http://www.cnblogs.com/qintangtao/archive/2012/11/17/2775209.html
MySQL Modify table structure