DDL(数据库定义语言)由create, alter,truncate,drop 组成。
1. create 创建表
create table 表名
(
属性名 属性类型 [约束条件],
....
);
2. alter 修改表结构
1. 新增新的列
alter table 表名 add 列名 类型 [default]
2. 改变列的顺序
alter table 表名 modify 列名 dataType 新列名
alter table 表明 modify 列名 first/last [某一列]
3. 修改列名必须要change
alter table 表名 change 旧表名 新表明 dataType [first | after] [default expression]
4. 删除列
alter table 表明 drop 列名
5. 重命名表
alter table 表名 rename 新表名
3.drop 删除表
drop table 表名
4. truncate 删除表中的全部数据,但是保留表结构。
174

被折叠的 条评论
为什么被折叠?



