1. 用例
本章介绍了如何创建,管理表及表的属性,如列定义和约束。
2. 静态
2.1 create table 创建表
create table tablename
(
column1 data_type1,
conlum2 data_type2,
...
);
null,not null约束列是否可为空.
default 确定默认值.
primary key 指定主健.
foreign key 指定外健.
使用unique确保值唯一.
使用check 创建检查约束.
2.2 使用create temporary table创建临时表
2.3 使用create table as 利用已存在的表创建新表
创建新表并向其中填充select 的结果.
2.4 alter table 更改现存表的结构
增加或删除列.修改列的数据类型.增加约束,重命名表名列名.
2.5 使用drop table 删除表
drop table tablename