Add, query, modify, and delete operations on data in basic SQL statements
1. create a database: create database <database Name>;
For example, create database student;
2. connect to an existing database: use <Database Name>;
For example, use student;
3. delete a database: drop database <database Name>;
For example, drop database student;
4. create a table: create table <table Name> (<column Name> <column data type> [<column constraints>])
For example, create table stuInfo (stuId int primary key, stuName varchar (20) not null)
5. delete a table: drop table <table Name>
For example, drop table stuInfo;
6. modify a table: alter table
Add a new column to the table: alter table <table Name> add <column Name> <column data type>;
Add multiple columns separated by commas
For 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>
For example, alter table stuInfo modify stuGender int
Alter column name: alter table <table Name> change <old column Name> <new column Name> <data type>
For example, alter table stuInfo change stuName stuAddress varchar (30)
Delete column: alter table <table Name> drop <column Name>
For example, alter table stuInfo drop stuGender
7. Export the Statement of the created table in reverse direction: show create table <table Name>
8. query all table content: select * from <Table Name>
Query part of the table: select <column Name List> from <Table Name>
9. query the table structure: show columns from <Table Name>
10. insert a single row of data: insert into <Table Name> (<column Name List>) values (<Value List>)
11. Insert multiple rows of data: It is equivalent to copying data from one table to another.
Insert into <Table Name> (column Name List) select <select statement>
For example, copy the names of all students in 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>
For example, delete the data of a person whose stuID is 4: delete from stuInfo where stuId = 4