1---------------Create a table------------------------------------
drop table if exists tables name
CREATE TABLE table name (ID int (one) primary key auto_increment, name varchar () not NULL); 2---------------Modify the table name of a table------------------------------------ALTER TABLE name 1 rename to table Name 2 explanation: Change table name 1 to table name 2demo:
ALTER TABLE TA1 Rename to ta0; 3---------------Add a field------------------------------------the name of the Alter table table name of the Add Column field varchar (a) NOT NULL default 1 Comment ' Interpretation of this field ' after the other fields are explained: After, the new field has a sort effect after the After field name segment. 4---------------Delete a field------------------------------------ALTER TABLE name drop field Name 5---------------Delete data/ Library (delete only data structures do not delete-----Drop is the entire table is deleted, including the table's data and the structure of the table. Truncate is the first to delete the entire table, in the establishment of the table structure, the data will be lost)------------------------------------drop database "name"; TRUNCATE TABLE name//delete data in table. "Free space, id resets" Delete from table name "row by row of deleted data, does not free up space, you can find that the ID of adding data data again is constantly superimposed" 6--------------- Modify field name------------------------------------ALTER TABLE name change old field new field varchar demo:alter table ta0 change names NA Me varchar (20); 7---------------Modify the field type------------------------------------ALTER TABLE name modify the new Type of Field field Demo:
ALTER TABLE TA0 modify uname int; 8----------------Query Statement-----------------------------------SELECT * FROM table name where + condition 9---------------- Insert statement-----------------------------------(1) INSERT into Table name values (field);
Demo
INSERT into TA1 values (1, ' 2 ');
(2) Insert into table name (field name) values (corresponding values);
Demo
Insert into TA1 (Id,username) VALUES (2, ' scatter '); ----------------UPDATE statement-----------------------------------the updated table name set field name = Value Demo:update ta1 set username= ' 4 ';
Summary of MySQL BASIC statement