forked from IBM/db2-nodejs-web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebstore.ddl
173 lines (119 loc) · 4.28 KB
/
webstore.ddl
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
--THIS FILE CONTAINS SQL WHICH CREATES TABLES AS USED BY THE MOCK WEBSTORE
-- This CLP file was created using DB2LOOK Version "11.1"
-- Timestamp: Wed Jun 14 18:19:14 2017
-- Database Name: WEBSTORE
-- Database Manager Version: DB2/LINUXX8664 Version 11.1.2.2
-- Database Codepage: 1208
-- Database Collating Sequence is: SYSTEM_819
-- Alternate collating sequence(alt_collate): null
-- varchar2 compatibility(varchar2_compat): OFF
-- You can create this database or replace with one you already have
-- Omit this line if copy-pasting into Run SQL in DSM
CONNECT TO WEBSTORE;
------------------------------------------------
-- DDL Statements for Schemas
------------------------------------------------
-- Running the DDL below will explicitly create a schema in the
-- new database that corresponds to an implicitly created schema
-- in the original database.
CREATE SCHEMA "WEBSTORE";
------------------------------------------------
-- DDL Statements for Table "WEBSTORE"."CUSTOMER"
------------------------------------------------
CREATE TABLE "WEBSTORE"."CUSTOMER" (
"C_SALUTATION" VARCHAR(5 OCTETS) ,
"C_LAST_NAME" VARCHAR(20 OCTETS) ,
"C_FIRST_NAME" VARCHAR(20 OCTETS) ,
"C_CUSTOMER_SK" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (
START WITH +1
INCREMENT BY +1
MINVALUE +1
MAXVALUE +2147483647
NO CYCLE
CACHE 20
NO ORDER ) )
IN "USERSPACE1"
ORGANIZE BY ROW;
-- DDL Statements for Primary Key on Table "WEBSTORE"."CUSTOMER"
ALTER TABLE "WEBSTORE"."CUSTOMER"
ADD CONSTRAINT "CUSTOMER_PK" PRIMARY KEY
("C_CUSTOMER_SK")
NOT ENFORCED;
ALTER TABLE "WEBSTORE"."CUSTOMER" ALTER COLUMN "C_CUSTOMER_SK" RESTART WITH 221;
------------------------------------------------
-- DDL Statements for Table "WEBSTORE"."INVENTORY"
------------------------------------------------
CREATE TABLE "WEBSTORE"."INVENTORY" (
"INV_ITEM_SK" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (
START WITH +1
INCREMENT BY +1
MINVALUE +1
MAXVALUE +2147483647
NO CYCLE
CACHE 20
NO ORDER ) ,
"INV_QUANTITY_ON_HAND" INTEGER NOT NULL WITH DEFAULT 0 )
IN "USERSPACE1"
ORGANIZE BY ROW;
-- DDL Statements for Primary Key on Table "WEBSTORE"."INVENTORY"
ALTER TABLE "WEBSTORE"."INVENTORY"
ADD CONSTRAINT "ITEM_PK" PRIMARY KEY
("INV_ITEM_SK")
NOT ENFORCED;
ALTER TABLE "WEBSTORE"."INVENTORY" ALTER COLUMN "INV_ITEM_SK" RESTART WITH 1001;
------------------------------------------------
-- DDL Statements for Table "WEBSTORE"."WEBSALES"
------------------------------------------------
CREATE TABLE "WEBSTORE"."WEBSALES" (
"WS_ORDER_NUMBER" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (
START WITH +1
INCREMENT BY +1
MINVALUE +1
MAXVALUE +2147483647
NO CYCLE
CACHE 20
NO ORDER ) ,
"WS_CUSTOMER_SK" INTEGER ,
"WS_QUANTITY" INTEGER NOT NULL WITH DEFAULT 1 ,
"WS_ITEM_SK" INTEGER )
IN "USERSPACE1"
ORGANIZE BY ROW;
-- DDL Statements for Primary Key on Table "WEBSTORE"."WEBSALES"
ALTER TABLE "WEBSTORE"."WEBSALES"
ADD CONSTRAINT "ORDER_NUMBER_PK" PRIMARY KEY
("WS_ORDER_NUMBER")
NOT ENFORCED;
ALTER TABLE "WEBSTORE"."WEBSALES" ALTER COLUMN "WS_ORDER_NUMBER" RESTART WITH 21;
------------------------------------------------
-- DDL Statements for Table "WEBSTORE"."TESTJSON"
------------------------------------------------
CREATE TABLE "WEBSTORE"."TESTJSON" (
"JSON_FIELD" BLOB(4000) INLINE LENGTH 4000 LOGGED NOT COMPACT )
IN "USERSPACE1"
ORGANIZE BY ROW;
-- DDL Statements for Foreign Keys on Table "WEBSTORE"."WEBSALES"
ALTER TABLE "WEBSTORE"."WEBSALES"
ADD CONSTRAINT "CUSTOMER_SK" FOREIGN KEY
("WS_CUSTOMER_SK")
REFERENCES "WEBSTORE"."CUSTOMER"
("C_CUSTOMER_SK")
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT ENFORCED
TRUSTED
ENABLE QUERY OPTIMIZATION;
ALTER TABLE "WEBSTORE"."WEBSALES"
ADD CONSTRAINT "ITEM_SK" FOREIGN KEY
("WS_ITEM_SK")
REFERENCES "WEBSTORE"."INVENTORY"
("INV_ITEM_SK")
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT ENFORCED
TRUSTED
ENABLE QUERY OPTIMIZATION;
-- Omit these lines if copy-pasting into Run SQL in DSM
COMMIT WORK;
CONNECT RESET;
TERMINATE;
-- Omit these lines if copy-pasting into Run SQL in DSM