Linux systems commonly used commands mysql

1. Start terminal MySQL: /etc/init.d/ MySQL Start; 
 2. Login MySQL: MySQL-uroot-- the p-(login account with root), then enter the password; 
 3 See all the database name: Show Databases;. 
 4 . select a database operation: use database_name; 
 5 to view the current list of all the names under the database:. Show the tables; 
 6 to create a database:. the create database database_name; 
 7 to delete a database:. database drop database_name; 
 8. create a table: create table mytest (UID BIGINT (20 is) Not null, the uname VARCHAR (20 is) Not null); 
 . 9 to delete a table:. table drop mytest; 
 10 the .SQL insert statement: insert into table_name (col1, col2 
 ) values (value1, value2); 11.SQL update statement: update table_name the SET col1 = ' value1 ' , col2 =' Value2 ' the WHERE where_definition; 
 12.SQL query: the SELECT * from table_name the WHERE ....... (the most complex statement) 1 
3.SQL delete statement: the Delete from table_name the WHERE ... 
 14 increased table structure. field: the Add Alert the table table_name column field1 DATE, the Add column Field2 Time ... 
 15 field delete table structure: Alert the table table_name drop field1;. 
 16. the structure of the table view: Show the Columns from table_name; 
 17.limit use: select * from table_name limit 3; // show only 3 lines per page * the SELECT from table_name limit 3, 4 // from the start of the third query results, display results of four. Here for a good deal for paging. 
18. Sort query results: the SELECT * from table_name field1 by the Order, the OrderBy Field2; multiple sorting
19 Exit MySQL: Exit; 
 20. The delete all the data in the table: truncate table table name (unrecoverable)

 

Guess you like

Origin www.cnblogs.com/123456www/p/12319225.html