Evaluation Guide : C. CREATE TABLE Statements
 
Share this page                  
CREATE TABLE Statements
On the WITH PARTITION clause, change 'NN' to the required number of partitions as described in Partitioning Tables and Configuring Database Resources.
CREATE TABLE customer (
c_custkey      INTEGER         NOT NULL
,c_name         VARCHAR(25)     NOT NULL
,c_address      VARCHAR(40)     NOT NULL
,c_nationkey    INTEGER         NOT NULL
,c_phone        CHAR(15)        NOT NULL
,c_acctbal      DECIMAL(18,2)   NOT NULL
,c_mktsegment   CHAR(10)        NOT NULL
,c_comment      VARCHAR(117)    NOT NULL
)
WITH NOPARTITION \g
 
 
CREATE TABLE lineitem (
l_orderkey             INTEGER         NOT NULL
,l_partkey              INTEGER         NOT NULL
,l_suppkey              INTEGER         NOT NULL
,l_linenumber           INTEGER         NOT NULL
,l_quantity             DECIMAL(18,2)   NOT NULL
,l_extendedprice        DECIMAL(18,2)   NOT NULL
,l_discount             DECIMAL(18,2)   NOT NULL
,l_tax                  DECIMAL(18,2)   NOT NULL
,l_returnflag           CHAR(1)         NOT NULL
,l_linestatus           CHAR(1)         NOT NULL
,l_shipDATE             DATE            NOT NULL
,l_commitDATE           DATE            NOT NULL
,l_receiptDATE          DATE            NOT NULL
,l_shipinstruct         CHAR(25)        NOT NULL
,l_shipmode             CHAR(10)        NOT NULL
,l_comment              VARCHAR(44)     NOT NULL
)
WITH PARTITION = (HASH ON l_orderkey NN PARTITIONS) \g
 
 
CREATE TABLE nation (
n_nationkey    INTEGER         NOT NULL
,n_name         CHAR(25)        NOT NULL
,n_regionkey    INTEGER         NOT NULL
,n_comment      VARCHAR(152)    NOT NULL
)
WITH NOPARTITION;
 
 
CREATE TABLE orders (
o_orderkey             INTEGER        NOT NULL
,o_custkey              INTEGER        NOT NULL
,o_orderstatus          CHAR(1)        NOT NULL
,o_totalprice           DECIMAL(18,2)  NOT NULL
,o_orderDATE            DATE           NOT NULL
,o_orderpriority        CHAR(15)       NOT NULL
,o_clerk                CHAR(15)       NOT NULL
,o_shippriority         INTEGER        NOT NULL
,o_comment              VARCHAR(79)    NOT NULL
)
WITH PARTITION = (HASH ON o_orderkey NN PARTITIONS) \g
 
 
CREATE TABLE partsupp (
ps_partkey     INTEGER         NOT NULL
,ps_suppkey     INTEGER         NOT NULL
,ps_availqty    INTEGER         NOT NULL
,ps_supplycost  DECIMAL(18,2)   NOT NULL
,ps_comment     VARCHAR(199)    NOT NULL
)
WITH PARTITION = (HASH ON ps_partkey, ps_suppkey NN PARTITIONS) \g
 
 
CREATE TABLE part (
p_partkey      INTEGER         NOT NULL
,p_name         VARCHAR(55)     NOT NULL
,p_mfgr         CHAR(25)        NOT NULL
,p_brand        CHAR(10)        NOT NULL
,p_type         VARCHAR(25)     NOT NULL
,p_size         INTEGER         NOT NULL
,p_container    CHAR(10)        NOT NULL
,p_retailprice  DECIMAL(18,2)   NOT NULL
,p_comment      VARCHAR(23)     NOT NULL
)
WITH NOPARTITION \g
 
 
CREATE TABLE region (
r_regionkey    INTEGER         NOT NULL
,r_name         CHAR(25)        NOT NULL
,r_comment      VARCHAR(152)    NOT NULL
)
WITH NOPARTITION \g
 
 
CREATE TABLE supplier (
s_suppkey      INTEGER         NOT NULL
,s_name         CHAR(25)        NOT NULL
,s_address      VARCHAR(40)     NOT NULL
,s_nationkey    INTEGER         NOT NULL
,s_phone        CHAR(15)        NOT NULL
,s_acctbal      DECIMAL(18,2)   NOT NULL
,s_comment      VARCHAR(101)    NOT NULL
)
WITH NOPARTITION \g