Mysql simple operation

//Mysql version: 5.7.13

 

1. Run the command prompt as an administrator and go to the installation location of
mysql 2. Start the mysql service: net start mysql        
3. Log in as root: mysql -uroot -p Enter key

4. List all databases: show databases;
5. Create a database: create databases Database_Name;
6. Determine whether it exists and then create a database: create databases if not exists Database_Name;
7. Delete a database: drop database Database_Name;
8. Select a database :use Database_Name;

9. List all data tables in the selected database: show tables;
10. Display the column details of the data table: show columns from Table_Name; or: describe Table_Name;
11. Select the display data table: select * from Table_Name;
12 .Display data table with conditions: select * from Table_Name where id>=2;
13. Create data table: create table Table_Name(col_01_Name Type Details,col_02_Name Type Details,...);
14. Judge first and then create data table: create table if not exists Table_Name(...);
15. Copy data table: create table Table_Name_01 select * from Table_Name_02;
16. Rename data table: alter table Table_Name rename as New_Table_Name; or: rename table Old_Name to New_Name;
17. Delete Data table: drop table Table_Name;

18. Add records to the data table: insert into Table_Name set col_01=Value1, col_02=Value2;
19. Modify records in the data table: update Table_Name set col_Name=New_Value where id=1;
20. Delete records in the data table: delete from Table_Name;
21. Delete records in the data table with conditions: delete from Table_Name where id=1;

22.#Current time view: select now();
23.#Current user: select user();
24.#Current database program version: select version();
25.#Current status: show status;
26.#View current Connected users: show processlist;

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326632898&siteId=291194637