语法
rename table 原表名 to 新表名; 【新版本】
alter table 表名 rename 新表名;
alter table 表名 drop 子段名称
MODIFY 子段名 数据类型[约束条件];
alter table 表名 CHANGE 旧字段 新字段 旧数据类型 [约束条件];
CHANGE 旧字段 新字段 新数据类型[约束条件];
alter table 表名 ADD 字段名 数据类型 [约束条件];
(可用FIRST AFTER 调整顺序)
alter table 表名 ADD 字段名 数据类型 [约束条件] FIRST;
alter table 表名 ADD 字段名 数据类型 [约束条件] AFTER 字段名;
复制表结构和数据
create table newtable select 所需字段(全部 *) from oldtable;
-------------------------------------------------------------------------
复制表结构
1. create table newtable select 所需字段(全部 *) from oldtable where 1=2;
原理 where 1=2 条件为false 查不到数据只复制表结构
2. create table newtable like oldtable;