1. Create libraries

create schema `test`;
Copy the code

2. Show the database

show databases;
Copy the code

3. Switch the database

use test;
Copy the code

4. Display table

show tables;
Copy the code

5, c-create create

Insert into users (username, password, phone) values (' username ', '123', '13333333333');Copy the code

6, r-read query

6.1 Querying All Information

select * from users; Select username, password from users;Copy the code

6.2 Conditional Query

Select * from users where username=' username '; Select * from users where username=' username 'and password='123'; Select * from users where username=' 123' or password='123'; Select * from users where username! = '* *'; Select * from users where username<>' username '; Select * from users where username = '% '; Select * form users order by id desc;Copy the code

7, u-update update

7.1 Updating All

update users set password='456';
Copy the code

7.2 Update with Conditions

Update users set password='456' where username=' 3 ';Copy the code

8. D-delete Delete

8.1 Deleting Table Data

Delete from users where username=' username ';Copy the code

8.2 soft delete

Update users set state='0' where username=' 1 '; select * from users where state='1';Copy the code