更新时间:2022-06-17 GMT+08:00

创建表

背景信息

表是建立在数据库中的,在不同的数据库中可以存放相同的表。甚至可以通过使用模式在同一个数据库中创建相同名称的表。创建表前请先规划存储模型

创建表

执行如下命令创建表。
1
2
3
4
5
6
7
8
9
CREATE TABLE customer_t1
(
    c_customer_sk             integer,
    c_customer_id             char(5),
    c_first_name              char(6),
    c_last_name               char(8)
)
with (orientation = column,compression=middle)
distribute by hash (c_last_name);

当结果显示为如下信息,则表示创建成功。

1
 CREATE TABLE

其中c_customer_sk 、c_customer_id、c_first_name和c_last_name是表的字段名,integer、char(5)、char(6)和char(8)分别是这四字段名称的类型。