1. Creating database: Create DB < database name >;
Such as: Create database student;
2. Connect to an existing database: Use < database name >;
such as: Use student;
3. Delete databases: Drop database < database name >;
such as: drop database student;
4. Creating table: Create table < table name > (< column name >< column data type >[< column constraint;])
such as: Create TABLE stuinfo (stuid int primary key,stuname varchar () NOT NULL)
5. Delete Table: Drop table < table name >
such as: drop table stuinfo;
6, modify the table: ALTER TABLE
To add a new column to a table: ALTER TABLE < table name > Add < column name >< column data type >;
Add multiple columns, separated by commas in the middle
such as: ALTER TABLE stuinfo add Stugender varchar (10)
Modify the data type of a column: ALTER TABLE < table name > Modify < column name >< new data type >
such as: ALTER TABLE stuinfo modify Stugender int
Modify column name: ALTER TABLE < table name > change < old column name >< new column name >< data type >
such as: ALTER TABLE stuinfo change stuname stuaddress varchar (30)
Delete column: ALTER TABLE < table name > drop < column name >
such as: ALTER TABLE Stuinfo drop Stugender
7. Reverse-Wizard The statement of the table you created: Show create table < table name >
8, all the contents of the query table: SELECT * FROM < table name >
Part of the query table: Select < column list > from < table name >
9. Query table structure: Show columns from < table name >
10. Insert single line data: INSERT into < table name > (< column list >) VALUES (< value list >)
11, inserting multiple rows of data: The role is equivalent to copy data from one table to another table
INSERT into < table name > (column list) select
If you copy all the student names from the Stuinfo table to the Stuname column in the students table: INSERT into students (stuname) select Stuname from Stuinfo
12, delete data: Delete from < table name > where< filter Conditions >
If you delete the data for the person who stuid 4: Delete from Stuinfo where stuid=4