MySQL database basic operations add, delete, check and modify the database

1 Start the service

	DOS命令
	net start mysql 回车

2 Log in to the MySQL database

	mysql -u root -p 回车
	输入密码

3 select database

	use 数据库名

4 View the database in MySQL

	show databases;

5 Create a database

	create database 数据库名;
	创建完毕,再次通过show databases 查看指令是否创建成功

6 delete the database

	drop database 数据库名;

7 create table

注释:
	在使用show 表名之前,必须先选择数据库。
	
	create table 表名(
	字段1 数据类型 [字段属性|约束][索引][注释]
	字段2 数据类型 [字段属性|约束][索引][注释]
	....
	字段n 数据类型 [字段属性|约束][索引][注释]
	)[表类型][表字符集][注释];

8 View table

注释:
	在使用show 表名之前,必须先选择数据库。否则将会报错误提示“No databaseselected”。
	
	show 表名;

9 Inquiry Form

	select * from 表名;

10 delete table

drop table ‘表名’;

11 add table

注释:
每个值和字段的类型对应一致,

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

12Add multiple records

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

Guess you like

Origin blog.csdn.net/xiao_xin_zhi/article/details/114081013