-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathcreate_table.sql
81 lines (77 loc) · 2.05 KB
/
create_table.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
create table part (
p_partkey bigint,
p_name varchar(30),
p_mfgr char(10),
p_category char(10),
p_brand1 char(10),
p_color varchar(20),
p_type varchar(30),
p_size bigint,
p_container char(10),
primary key(p_partkey)
);
create table supplier(
s_suppkey bigint,
s_name char(30),
s_address varchar(30),
s_city char(20),
s_nation char(20),
s_region char(20),
s_phone char(20),
primary key(s_suppkey)
);
create table customer(
c_custkey bigint,
c_name varchar(30),
c_address varchar(30),
c_city char(20),
c_nation char(20),
c_region char(20),
c_phone char(20),
c_mktsegment char(20),
primary key(c_custkey)
);
create table date(
d_datekey bigint,
d_date char(20),
d_dayofweek char(10),
d_month char(10),
d_year bigint,
d_yearmonthnum bigint,
d_yearmonth char(10),
d_daynuminmonth bigint,
d_daynuminyear bigint,
d_monthnuminyear bigint,
d_weeknuminyear bigint,
d_sellingseason char(20),
d_lastdayinweekfl bigint,
d_lastdayinmonthfl bigint,
d_holidayfl bigint,
d_weekdayfl bigint,
primary key(d_datekey)
);
create table lineorder (
lo_orderkey bigint,
lo_linenumber bigint,
lo_custkey bigint,
lo_partkey bigint,
lo_suppkey bigint,
lo_orderdate bigint,
lo_orderpriority char(20),
lo_shippriority char(1),
lo_quantity bigint,
lo_extendedprice bigint,
lo_ordtotalprice bigint,
lo_discount bigint,
lo_revenue bigint,
lo_supplycost bigint,
lo_tax bigint,
lo_commitdate bigint,
lo_shipmode char(10),
primary key(lo_orderkey, lo_linenumber),
constraint foreign key lineorder_fk1(lo_custkey) references customer(c_custkey),
constraint foreign key lineorder_fk2(lo_partkey) references part(p_partkey),
constraint foreign key lineorder_fk3(lo_suppkey) references supplier(s_suppkey),
constraint foreign key lineorder_fk4(lo_orderdate) references date(d_datekey),
constraint foreign key lineorder_fk5(lo_commitdate) references date(d_datekey)
);