1. Creating database: Create databases < 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;])
Example: Create TABLE Stuinfo (stuid int primary key,stuname varchar () NOT NULL)
5. Delete tables: drop table < table name >
such as: drop table stuinfo;
6, modify the table: ALTER TABLE
Add a new column to a table: ALTER TABLE < table name > Add < column name >< column data type >;
Add multiple columns, separated by commas
Example: 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 >
Example: ALTER TABLE stuinfo change stuname stuaddress varchar (30)
Delete columns: ALTER TABLE < table name > drop < column name >
such as: ALTER TABLE Stuinfo drop Stugender
7. The statement of the created table is reversed: Show create table < table name >
8. Querying all contents of the table: SELECT * FROM < table name >
Partial contents of the query table: Select < column Name list > from < table names >
9. Query table structure: Show columns from < table name >
10. Insert single row of data: INSERT into < table name > (< column list >) VALUES (< value list >)
11. Inserting multiple rows of data: acts as copying data from one table to another
INSERT into < table name > (List of column names) Select <select Statement >
If you copy all 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 Condition >
If you delete data for a person Stuid 4: Delete from Stuinfo where stuid=4
Basic SQL statement Operation data additions and deletions check and change