cd C:\Program Files\MySQL\MySQL Server 8.0\bin
Enter password: ********
CREATE TABLE region
(regionkey INT PRIMARY KEY,
name CHAR(25),
comment VARCHAR(150)
);
CREATE TABLE nation
(nationkey INT PRIMARY KEY,
name CHAR(25),
comment VARCHAR(150),
regionkey INT,
FOREIGN KEY(regionkey)REFERENCES region(regionkey)
);
CREATE TABLE supplier
(suppkey INT PRIMARY KEY,
name CHAR(100),
address VARCHAR(100),
nationkey INT,
FOREIGN KEY(nationkey)REFERENCES nation(nationkey),
phone CHAR(30),
acctbal NUMERIC(12,2),
comment VARCHAR(100)
);
CREATE TABLE part
(partkey INT PRIMARY KEY,
name VARCHAR(100),
mfgr CHAR(50),
brand CHAR(50),
type VARCHAR(25),
size INT,
container CHAR(10),
retailprice NUMERIC(8,2),
comment VARCHAR(20)
);
CREATE TABLE partsupp
(partkey INT,
suppkey INT,
PRIMARY KEY(partkey,suppkey),
FOREIGN KEY(partkey)REFERENCES part(partkey),
FOREIGN KEY(suppkey)REFERENCES supplier(suppkey),
availqty INT,
supplycost NUMERIC(10,2),
comment VARCHAR(200)
);
CREATE TABLE customer
(custkey INT PRIMARY KEY,
name VARCHAR(25),
address VARCHAR(40),
nationkey INT,
FOREIGN KEY(nationkey)REFERENCES nation(nationkey),
phone CHAR(30),
acctbal NUMERIC(12,2),
mktsegment CHAR(10),
comment VARCHAR(100)
);
CREATE TABLE orders
(orderkey INT PRIMARY KEY,
custkey INT,
FOREIGN KEY(custkey)REFERENCES customer(Custkey),
orderstatus CHAR(1),
totalprice NUMERIC(10,2),
orderdate DATE,
orderpriority CHAR(15),
clerk CHAR(16),
shippriority CHAR(1),
comment VARCHAR(60)
);
CREATE TABLE lineitem
(orderkey INT,
partkey INT,
suppkey INT,
linenumber INT,
quantity INT,
extendedprice NUMERIC(8,2),
discount NUMERIC(3,2),
tax NUMERIC(3,2),
returnflag CHAR(1),
linestatus CHAR(1),
shipdate DATE,
commitdate DATE,
receiptdate DATE,
shipinstruct CHAR(25),
shipmode CHAR(10),
comment VARCHAR(40),
FOREIGN KEY(orderkey)REFERENCES orders(orderkey),
FOREIGN KEY(partkey)REFERENCES part(partkey),
FOREIGN KEY(suppkey)REFERENCES supplier(suppkey),
PRIMARY KEY(orderkey,linenumber),
FOREIGN KEY(partkey,suppkey)REFERENCES partsupp(partkey,suppkey)
);