创建表
create table 数据库名.表名(
字段1 数据类型,
字段2 数据类型,
...
);
查看表
查看表的基本结构:
describe 表名;
查看表的详细结构:
show create table 表名;
修改表名
alter table 旧表名 rename [to] 新表名;
修改字段类型
alter table 表名 modify 字段名 新的字段类型;
alter table 表名 modify 字段名1 新字段类型1, modify 字段名2 新字段类型2, ···, modify 字段名n 新字段类型n;
修改字段名
alter table 表名 change 旧字段名 新字段名 旧字段类型;
同时修改字段名和数据类型
alter table 表名 change 旧字段名 新字段名 新字段类型;
增加字段
alter table 表名 add 字段名1 字段类型 [first|after first|after 字段名2];
修改字段的排列位置
alter table 表名 modify 字段名1 字段类型 first|after 字段名2;
删除字段
alter table 表名 drop 字段名;
删除表
drop table 表名;