产品概述
应用场景
节点规格
集群架构
CREATE TABLE命令创建表,格式如下:CREATE TABLE table_name ([ { column_name data_type [ DEFAULT default_expr ] -- 表的列定义[column_constraint [ ... ] -- 列的约束定义]| table_constraint -- 表级别的约束定义])[ WITH ( storage_parameter=value [, ... ] ) -- 表存储格式定义[ DISTRIBUTED BY (column, [ ... ] ) | DISTRIBUTED RANDOMLY ] -- 表的分布键定义[ partition clause] -- 表的分区定义
CREATE TABLE sales (trans_id int,date date,amount decimal(9,2),region text)DISTRIBUTED BY (trans_id)PARTITION BY RANGE(date)(start (date '2018-01-01') inclusiveend (date '2019-01-01') exclusive every (interval '1 month'),default partition outlying_dates);
CREATE TEMPORARY TABLE table_name(…)[ON COMMIT {PRESERVE ROWS | DELETE ROWS | DROP}]
CREATE TEMPORARY TABLE temp_foo (a int, b text) ON COMMIT DROP;
UNIQUE ( column_name [, ... ] )| PRIMARY KEY ( column_name [, ... ] )| CHECK ( expression )
CREATE TABLE products( product_no integer,name text,price numeric CHECK (price > 0) );
CREATE TABLE products( product_no integer NOT NULL,name text NOT NULL,price numeric );
CREATE TABLE products( product_no integer UNIQUE,name text,price numeric)DISTRIBUTED BY (product_no);
CREATE TABLE products( product_no integer PRIMARY KEY,name text,price numeric)DISTRIBUTED BY (product_no);
文档反馈