You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
1.5 KiB
19 lines
1.5 KiB
3 years ago
|
ALTER TABLE tpch.supplier ADD PRIMARY KEY (s_suppkey);
|
||
|
ALTER TABLE tpch.partsupp ADD PRIMARY KEY (ps_partkey, ps_suppkey);
|
||
|
ALTER TABLE tpch.part ADD PRIMARY KEY (p_partkey);
|
||
|
ALTER TABLE tpch.customer ADD PRIMARY KEY (c_custkey);
|
||
|
ALTER TABLE tpch.orders ADD PRIMARY KEY (o_orderkey);
|
||
|
ALTER TABLE tpch.lineitem ADD PRIMARY KEY (l_orderkey, l_linenumber);
|
||
|
ALTER TABLE tpch.nation ADD PRIMARY KEY (n_nationkey);
|
||
|
ALTER TABLE tpch.region ADD PRIMARY KEY (r_regionkey);
|
||
|
|
||
|
ALTER TABLE tpch.supplier ADD CONSTRAINT supplier_nation_fk FOREIGN KEY (s_nationkey) REFERENCES tpch.nation (n_nationkey);
|
||
|
ALTER TABLE tpch.partsupp ADD CONSTRAINT partsupp_part_fk FOREIGN KEY (ps_partkey) REFERENCES tpch.part (p_partkey);
|
||
|
ALTER TABLE tpch.partsupp ADD CONSTRAINT partsupp_supplier_fk FOREIGN KEY (ps_suppkey) REFERENCES tpch.supplier (s_suppkey);
|
||
|
ALTER TABLE tpch.customer ADD CONSTRAINT customer_nation_fk FOREIGN KEY (c_nationkey) REFERENCES tpch.nation (n_nationkey);
|
||
|
ALTER TABLE tpch.orders ADD CONSTRAINT orders_customer_fk FOREIGN KEY (o_custkey) REFERENCES tpch.customer (c_custkey);
|
||
|
ALTER TABLE tpch.lineitem ADD CONSTRAINT lineitem_order_fk FOREIGN KEY (l_orderkey) REFERENCES tpch.orders (o_orderkey);
|
||
|
ALTER TABLE tpch.lineitem ADD CONSTRAINT lineitem_part_fk FOREIGN KEY (l_partkey) REFERENCES tpch.part (p_partkey);
|
||
|
ALTER TABLE tpch.lineitem ADD CONSTRAINT lineitem_partsupp_fk FOREIGN KEY (l_partkey, l_suppkey) REFERENCES tpch.partsupp (ps_partkey, ps_suppkey);
|
||
|
ALTER TABLE tpch.nation ADD CONSTRAINT nation_region_fk FOREIGN KEY (n_regionkey) REFERENCES tpch.region (r_regionkey);
|