mysql simple review

For a long time did not play a simple sql to review the case, really afraid someday amnesia QAQ

 

Switch to administrator

sudo -s

 

 

Log database , enter the password

mysql -u root -p

 

View all databases

show databases;

 

 

Create a database

create database web02;

 

Delete Database

drop database web03;

 

 

Use Database

use web02;

 

View current database used

select database();

 

Create a database table

create table user(id int primary key auto_increment,username varchar(16),password varchar(16));

Create a user table, the above mentioned id as the primary key, use the integer, and increment, username and password are used 16 space to store the size of the characters

 

To delete a database table

drop table user;

 

View database tables structure

desc  user ;

 

Inserting data into a database table

insert into user values (null,”siki”,”123”);

Inserted into a database table id increment, user name Siki, password 123 recorded

 

 

Inserting data into the database table (key pairing mode)

Insert into user(username,password) values(‘Jack’,’123456’);

To the user to insert a table username is Jack , password is 123456 records

 

 

All recorded data table view

select  *  from  user ;

 

Delete all records in a database table

delete from user;

 

Delete database records specified in the table

Delete from user where id = 3;

Delete user database table id as 3 record

 

Renaming database tables

Rename table user user to myuser;

 

Guess you like

Origin www.cnblogs.com/lightice/p/11490034.html