|
| 1 | +-- Adapted from the Postgres schema |
| 2 | +DROP TABLE IF EXISTS lineitem; |
| 3 | +DROP TABLE IF EXISTS orders; |
| 4 | +DROP TABLE IF EXISTS customer; |
| 5 | +DROP TABLE IF EXISTS partsupp; |
| 6 | +DROP TABLE IF EXISTS part; |
| 7 | +DROP TABLE IF EXISTS supplier; |
| 8 | +DROP TABLE IF EXISTS nation; |
| 9 | +DROP TABLE IF EXISTS region; |
| 10 | + |
| 11 | +CREATE TABLE region ( |
| 12 | + r_regionkey integer NOT NULL, |
| 13 | + r_name char(25) NOT NULL, |
| 14 | + r_comment varchar(152), |
| 15 | + INDEX region_cstore CLUSTERED COLUMNSTORE, |
| 16 | + -- PRIMARY KEY (r_regionkey), |
| 17 | + INDEX r_rk UNIQUE (r_regionkey ASC), |
| 18 | +); |
| 19 | + |
| 20 | +CREATE TABLE nation ( |
| 21 | + n_nationkey integer NOT NULL, |
| 22 | + n_name char(25) NOT NULL, |
| 23 | + n_regionkey integer NOT NULL, |
| 24 | + n_comment varchar(152), |
| 25 | + INDEX nation_cstore CLUSTERED COLUMNSTORE, |
| 26 | + -- PRIMARY KEY (n_nationkey), |
| 27 | + INDEX n_nk UNIQUE (n_nationkey ASC), |
| 28 | + INDEX n_rk (n_regionkey ASC), |
| 29 | + FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) |
| 30 | +); |
| 31 | + |
| 32 | +CREATE TABLE part ( |
| 33 | + p_partkey integer NOT NULL, |
| 34 | + p_name varchar(55) NOT NULL, |
| 35 | + p_mfgr char(25) NOT NULL, |
| 36 | + p_brand char(10) NOT NULL, |
| 37 | + p_type varchar(25) NOT NULL, |
| 38 | + p_size integer NOT NULL, |
| 39 | + p_container char(10) NOT NULL, |
| 40 | + p_retailprice decimal(15, 2) NOT NULL, |
| 41 | + p_comment varchar(23) NOT NULL, |
| 42 | + INDEX part_cstore CLUSTERED COLUMNSTORE, |
| 43 | + -- PRIMARY KEY (p_partkey) |
| 44 | + INDEX p_pk UNIQUE (p_partkey ASC) |
| 45 | +); |
| 46 | + |
| 47 | +CREATE TABLE supplier ( |
| 48 | + s_suppkey integer NOT NULL, |
| 49 | + s_name char(25) NOT NULL, |
| 50 | + s_address varchar(40) NOT NULL, |
| 51 | + s_nationkey integer NOT NULL, |
| 52 | + s_phone char(15) NOT NULL, |
| 53 | + s_acctbal decimal(15, 2) NOT NULL, |
| 54 | + s_comment varchar(101) NOT NULL, |
| 55 | + INDEX supplier_cstore CLUSTERED COLUMNSTORE, |
| 56 | + -- PRIMARY KEY (s_suppkey), |
| 57 | + INDEX s_sk UNIQUE (s_suppkey ASC), |
| 58 | + INDEX s_nk (s_nationkey ASC), |
| 59 | + FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) |
| 60 | +); |
| 61 | + |
| 62 | +CREATE TABLE partsupp ( |
| 63 | + ps_partkey integer NOT NULL, |
| 64 | + ps_suppkey integer NOT NULL, |
| 65 | + ps_availqty integer NOT NULL, |
| 66 | + ps_supplycost decimal(15, 2) NOT NULL, |
| 67 | + ps_comment varchar(199) NOT NULL, |
| 68 | + INDEX partsupp_cstore CLUSTERED COLUMNSTORE, |
| 69 | + -- PRIMARY KEY (ps_partkey, ps_suppkey), |
| 70 | + INDEX ps_pk (ps_partkey ASC), |
| 71 | + INDEX ps_sk (ps_suppkey ASC), |
| 72 | + INDEX ps_pk_sk UNIQUE (ps_partkey ASC, ps_suppkey ASC), |
| 73 | + INDEX ps_sk_pk UNIQUE (ps_suppkey ASC, ps_partkey ASC), |
| 74 | + FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey), |
| 75 | + FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) |
| 76 | +); |
| 77 | + |
| 78 | +CREATE TABLE customer ( |
| 79 | + c_custkey integer NOT NULL, |
| 80 | + c_name varchar(25) NOT NULL, |
| 81 | + c_address varchar(40) NOT NULL, |
| 82 | + c_nationkey integer NOT NULL, |
| 83 | + c_phone char(15) NOT NULL, |
| 84 | + c_acctbal decimal(15, 2) NOT NULL, |
| 85 | + c_mktsegment char(10) NOT NULL, |
| 86 | + c_comment varchar(117) NOT NULL, |
| 87 | + INDEX customer_cstore CLUSTERED COLUMNSTORE, |
| 88 | + -- PRIMARY KEY (c_custkey), |
| 89 | + INDEX c_ck UNIQUE (c_custkey ASC), |
| 90 | + INDEX c_nk (c_nationkey ASC), |
| 91 | + FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) |
| 92 | +); |
| 93 | + |
| 94 | +CREATE TABLE orders ( |
| 95 | + o_orderkey integer NOT NULL, |
| 96 | + o_custkey integer NOT NULL, |
| 97 | + o_orderstatus char(1) NOT NULL, |
| 98 | + o_totalprice decimal(15, 2) NOT NULL, |
| 99 | + o_orderdate date NOT NULL, |
| 100 | + o_orderpriority char(15) NOT NULL, |
| 101 | + o_clerk char(15) NOT NULL, |
| 102 | + o_shippriority integer NOT NULL, |
| 103 | + o_comment varchar(79) NOT NULL, |
| 104 | + INDEX o_orderdate_idx CLUSTERED COLUMNSTORE, |
| 105 | + -- PRIMARY KEY (o_orderkey), |
| 106 | + INDEX o_ok UNIQUE (o_orderkey ASC), |
| 107 | + INDEX o_ck (o_custkey ASC), |
| 108 | + INDEX o_od (o_orderdate ASC), |
| 109 | + FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) |
| 110 | +); |
| 111 | + |
| 112 | +CREATE TABLE lineitem ( |
| 113 | + l_orderkey integer NOT NULL, |
| 114 | + l_partkey integer NOT NULL, |
| 115 | + l_suppkey integer NOT NULL, |
| 116 | + l_linenumber integer NOT NULL, |
| 117 | + l_quantity decimal(15, 2) NOT NULL, |
| 118 | + l_extendedprice decimal(15, 2) NOT NULL, |
| 119 | + l_discount decimal(15, 2) NOT NULL, |
| 120 | + l_tax decimal(15, 2) NOT NULL, |
| 121 | + l_returnflag char(1) NOT NULL, |
| 122 | + l_linestatus char(1) NOT NULL, |
| 123 | + l_shipdate date NOT NULL, |
| 124 | + l_commitdate date NOT NULL, |
| 125 | + l_receiptdate date NOT NULL, |
| 126 | + l_shipinstruct char(25) NOT NULL, |
| 127 | + l_shipmode char(10) NOT NULL, |
| 128 | + l_comment varchar(44) NOT NULL, |
| 129 | + INDEX l_shipdate_idx CLUSTERED COLUMNSTORE, |
| 130 | + -- PRIMARY KEY (l_orderkey, l_linenumber), |
| 131 | + INDEX l_ok (l_orderkey ASC), |
| 132 | + INDEX l_pk (l_partkey ASC), |
| 133 | + INDEX l_sk (l_suppkey ASC), |
| 134 | + INDEX l_sd (l_shipdate ASC), |
| 135 | + INDEX l_cd (l_commitdate ASC), |
| 136 | + INDEX l_rd (l_receiptdate ASC), |
| 137 | + INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC), |
| 138 | + INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC), |
| 139 | + FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey), |
| 140 | + FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) |
| 141 | +); |
0 commit comments