Basic operation of MySQL database: Create/Drop database, table addition, deletion, modification and check

1. Start the service

DOS command

net start mysql 回车

2. Log in to the MySQL database

 mysql -uroot -proot 回车

3. View the database in MySQL

show databases;

4. Create a database

create database 数据库名;

After the creation is completed, check whether the creation is successful again through the show databases; command

5. Delete the database

drop database 数据库名;

6. Create Table

Note: Before operating the verse, "use the database"

use 数据库名;

Create table

create table 表名(字段1 数据类型(字符长度) ,字段2 数据类型(长度) not null)

PRIMAPY KEY(字段1);

Insert picture description here

7 Add a single record in the table

insert into 表名(字段1,字段2.....) valus(1,值2.......)

Note: Each value corresponds to the type of the field

Reference case screenshot
Insert picture description here

8. Inquiry

select * from 表名

Refer to the screenshots (I don’t check if data is added after connecting to the top)

Insert picture description here

9. Add multiple records

insert into 表名(字段1,字段2.....) valus(值A1,值A2.......),(值B1,值AB.......)

Reference screenshot

Insert picture description here

10. Delete

delete from 表名;

Reference screenshot;

Insert picture description here

11. Modify

update 表名 set 字段1=1,字段2=2.....;

Note that each value and field type correspond
to the screenshot of the reference case

Insert picture description here

Guess you like

Origin blog.csdn.net/sumo155/article/details/114081175
Recommended