Commands in the system
Mysqlshow viewing libraries in MySQL
Mysqlshow Library name View tables in a specified library
Commands in MySQL
Create creates
Create database name; Create a library
CREATE TABLE table name (column name option, column name option, ...); Create a table
Create replication Table is replicated table name: T1
New table name: T2
CREATE TABLE T2 like T1; Duplicate table structure
CREATE table T2 as select * from T1; Completely copy the table (as can not be written)
CREATE TABLE T2 as select Id,name from T1; Copy the specified column contents (as can not be written)
CREATE TABLE T2 as SELECT * from T1 where column name = value; Copy the contents of the specified condition (as can not be written)
Show view database structure
show databases; View the libraries that exist
Show tables; To view tables that exist in the library
Option: Full Open
Show full tables; View the files in the library and indicate whether they are tables or views
Show open tables; To view the memory-open tables in the system
flush Tables; Empty the Open table in system memory
Show columns from table name; View column information in a table
Show fields from table name; View column information in a table
Show CREATE table name \g View specific information about the properties and tables specified by the table , note: This is the only way to query table properties
Describe
describe table name; View the data type for each column of a table structure
can be abbreviated DESC table name;
Explain
explain T1; very powerful table editing tools
Select View Data
Select Database (); View the library in which it resides
View Table Contents
SELECT * from table name; View all column contents of a table
Select column 1, column 2 ... from table name; View table specified column contents, display column order can be defined by itself
Select specifies the column from the table name limit [Specify the starting row], showing the number of rows; View table specified row contents, specify starting line default first behavior "0"
Select specifies the column from table name where column name = value; Finds the row for the specified content, with a single quotation mark when the value is not a number
Select specifies the column from table name where column name is null; Finds the row in a specified column in a table that contains null values
Use login
Use library name; Enter the specified library
Drop Delete
drop database name; Delete a library
drop table name; Delete a table
INSERT INTO Inserts data
Insert into table name (column 1, column 2, ...) Values (value 1, value 2, ...) ); Inserting data into the specified table
INSERT INTO T2 select * from T1; Inserting T1 table contents into the T2 table
INSERT INTO T1 select * from T1; Copy the contents of a table
Handler viewing data
You must open a table before you can view data
Handler table name open [[as] alias];
HANDLER tbl_name READ column name {= | <= | >= | < | >} (value1,value2,...)
[WHERE Where_condition] [LIMIT ...]
HANDLER Tbl_name READ index_name {First | NEXT | PREV | Last}
[WHERE Where_condition] [LIMIT ...]
HANDLER tbl_name READ {First | NEXT}
[WHERE Where_condition] [LIMIT ...]
HANDLER tbl_name Close Closed table
Rename Table Rename
Rename table name to new table name; Table renaming
Truncate
TRUNCATE TABLE name; Clear Table Contents
This article is from "Sure to receive" blog, please be sure to keep this source http://8850775.blog.51cto.com/8840775/1854723
MySQL basic command