1、DDL——数据库操作
show databases; 显示所有数据库
create database [if not exists] 数据库名; 创建数据库
use 数据库名; 使用指定数据库
select database(); 查询当前使用的数据库
drop database [if exists] 数据库名; 删除数据库
2、DDL——表操作
show tables; 显示当前数据库下的所有表格
create table 表名 (字段 字段类型......); 创建表格
desc 表名; 显示表格
show creat table 表名 [\G] 显示表格代码信息[格式化输出]
alter table 表名 add 字段名 类型 [after 指定字段名] [comment 注释] [约束];
alter table 表名 modify 已有字段名 新的数据类型;
alter table 表名 change 已有字段名 新的字段名 新的数据类型 [comment 注释] [约束];
alter table 表名 drop 字段名 ;
alter table 表名 rename to 新表名;
drop table [if exists] 表名; 删除表
truncate table 表名; 删除表中的所有数据