show databases;
select database;
use 数据库名;
create database [if not exists] 数据库名 [default charest utf8mb4];
drop database [if exist] 数据库名;
create table tablename(
字段1 字段类型 [约束] [comment 字段1的注解]
字段2 字段类型 [约束] [comment 字段2的注解]
......
)[comment 表注解]
1)查询当前数据库所有表
show tables;
2)查询表结构
desc 表名;
3)查询建表语句
show create table 表名;
1)添加字段
alter table 表名 add 字段 数据类型(长度) [comment 注解] [约束];
2)修改字段类型
alter table 表名 modify 字段名 新数据类型(长度);
3)修改字段名
alter table 表名 change 旧字段 新字段 数据类型(长度) [comment 注解] [约束];
4)删除字段
alter table 表名 drop colum 字段名;
5)修改表名
alter table 旧表名 rename to 新表名;
drop table [if exists] 表名;
insert into 表名(字段1,字段2) values(值1,值2);
insert into 表名 values (值1,值2,...);
insert into 表名(字段1,字段2) values(值1,值2),(值1,值2)...;
insert into 表名 values (值1,值2,...),(值1,值2,...);
update 表名 set 字段1 = 值1 ,字段2 = 值2 ,... ,where 条件;
delete from 表名 where 条件;