Note: MySQL database is case-insensitive. 1. create a database: createdatabaseThinkgamer; 2. delete a database: dropdatabaseThinkgamer; 3. select a database: useThinkgamer; 4. create a data table: mysqlcreatetable. note: mySQL database is case-insensitive
1. create a database:Create database Thinkgamer;
2. delete a database:Drop database Thinkgamer;
3. select a database:Use Thinkgamer;
4. create a data table:
Mysql> create table cyan
-> (
-> Student ID int (3) not null primary key,
-> Name char (3 );
-> Gender char (1) not null default 1
->) Engine = innodb;
Press Enter. not null indicates that this field cannot be blank. primary key indicates that the primary key is set and default name is 1 by default.
5. delete a table:Drop table cyan;
6. add columns to the table:Alter table cyan add char (20 );
7. display information about the table:Describe cyan;
8. display the information of a column:Select student ID from cyan;
9. add information to the table:Insert cyan values ("111", "Thinkgamer", "female", "Dance ");
10. modify the information of a table row:
Mysql> update cyan
-> Set gender = "male", hobbies = "Badminton"
-> Where student no. = 111;
Press Enter.
1. modify the information of multiple tables:
Mysql> update table_name1, table_name2
-> Set table_name1. Gender = "male", table_name2. Gender = "female"
-> Where table_name1.id = table_name2.id;
Press Enter.
12. delete a row:Delete from cyan where student ID = 111;
13. remove a person with a gender:Delete from cyan where gender = female;
14. delete multiple rows from multiple tables:
Mysql> delete table1, table2
-> From table1, table2, table3
-> Where table1.id = table2.id and table2.id = table3.id;
Press Enter.
15. clear table data:Truncate table cyan;
Note: Once the data is cleared, it cannot be recovered.
Others:
Select user (); displays the current user.
Select @ version; displays the database version.
Show cyan status; displays the status of the currently used table
Show character set; displays the character sets supported by the database
Show variables like '% char %' view default character set