Log in to MySQL
mysql-uroot-phd792310
See which libraries are currently available
show databases;
Where library Tese is empty by default
Switch Library commands
Use Discuz or used MySQL is not added;
View current in that library
Mysql> Select Database ();
View Current User
Mysql> Select User ();
View current MySQL database version information
Mysql> select version ();
Several key knowledge of the database:
----------The field library contains the table, the table has rows, and there are fields in the row
See which tables are in the current library
Mysql> Show tables;
View a table pre_ucenter_vars, what are the descriptive information
mysql> desc Pre_ucenter_vars;
See how a table Pre_ucenter_vars is created, what its creation statement is
Mysql> Show CREATE TABLE pre_ucenter_vars\g; \g to make the layout beautiful
Create a custom Library
Create Database Wyp; To create a WYP library
Create a table in the WYP library Llzd
Use WYP switch to the WYP library
CREATE TABLE LLZD (' id ' int (4), ' name ' char (+) ') Engine=myisam DEFAULT CHARSET=GBK;
CREATE TABLE LLZD,ID length 4,name length 40, engine MyISAM default character set GBK
Create a table and insert a field in the Llzd table
INSERT into LLZD values (1, ' wuyaoping ');
1 represents the id ' wuyaoping ' for name, because it is char and must be enclosed in single quotation marks
Or insert only one field
mysql> INSERT INTO LLZD (' id ') values (2); Insert ID only
mysql> INSERT INTO Llzd (' name ') VALUES (' 55 '); Insert name only best Plus single quote
mysql> INSERT INTO Llzd (' name ', ' ID ') VALUES (' 66 ', 5); Flag can be reversed, same effect
View rows in a specified table
Mysql> select * from Llzd; Can see the information to 1,wuyaoping
In a table, update the fields in the table
mysql> Update llzd set id=4 where name = ' 66 '; after matching name, update ID
In a table, delete a row in the table
Mysql> Delete from Llzd where id=1;
or mysql> delete from llzd where name= ' wuyaoping ';
Empty the contents of a table
mysql> truncate TABLE wyp.llzd; Specify Library WYP and table Llzd
Delete a table
mysql> drop table Llzd;
Delete a library
mysql> drop Database Wyp;
3.3-mysql Common Operations-1