《创建和显示》
1.创建数据库:create database 数据库名 ;
2.删除数据库:drop database 数据库名 ;
3.查看数据库:show databases ;
4.查看所有表:show tables ;
5.查看表结构:desc / describe 表名 ;
6.创建表:create table 表名() ; Tips:加判断 if not exists
7.删除表:drop table 表名 ; Tips:加判断 if exists
8.创建临时表:create temporary table 表名 ( 查询语句 );
《更改》alter 更改
1.修改表名:alter table 旧表名 rename 新表名 ;
2.添加新列:alter table 表名 add 列名 数据类型 [约束] ;
3.删除旧列:alter table 表名 drop 列名 ;
4.修改旧列:alter table 表名 change 旧列名 新列名 数据类型 [约束] ;
5.添加主键:alter table 表名 add primary key (列名) ;
6.删除主键:alter table 表名 drop primary key ;
7.添加外键:alter table 外表名 add constraint 外键约束名 foreign key (外键) ref