Special NOTE: MySQL database is not case-sensitive
1, create the database: creating databasesThinkgamer;
2. Delete databases:drop database thinkgamer;
3, select a database: Usethinkgamer;
4. Create a data table:
Mysql>create Table Cyan
(
-ID INT (3) NOT null primary key,
Name char (3);
--Sex char (1) NOT NULL default 1
) engine = InnoDB;
Enter, not null set the field cannot be empty, primary key is set primary key, default name is 1.
5. Delete tables:drop table cyan;
6. Add columns to the table:ALTER TABLE cyan Add hobby char (a);
7, display the relevant information of the table:describe cyan;
8, display a column of information:Select school number from cyan;
9, add informationto the table: Insert Cyan VALUES ("111", "Thinkgamer", "female", "Dance");
10. Modify a table for a row of information:
Mysql>update Cyan
->set sex = "male", hobby = "Badminton"
->where No. = 111;
You can enter.
1 . Modify some information for multiple tables:
Mysql>update table_name1,table_name2
->set table_name1. Sex = "male", table_name2. Sex = "female"
->where table_name1.id = table_name2.id;
You can enter.
12. Delete a line: Delete fromcyan where study number =111;
13. Delete the gender-female:Delete from cyan where sex = 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;
You can enter.
15, clear the table data:truncate TABLE cyan;
Note: Once the data is cleared, it cannot be recovered.
Other:
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; Display the character set supported by the database
Show variables like '%char% ' viewing the default character set
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"MySQL" MySQL database operation command Daquan