-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_data.sql
48 lines (43 loc) · 1.04 KB
/
load_data.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
begin;
drop table if exists customer;
create table customer (
customerid int,
name text,
address text,
citystatezip text,
birthdate date,
phone text
);
\copy customer from 'noahs-customers.csv' with csv header
create index on customer(customerid);
drop table if exists orders;
create table orders (
orderid int,
customerid int,
ordered timestamp,
shipped timestamp,
items int,
total decimal
);
\copy orders from 'noahs-orders.csv' with csv header
create index on orders(orderid);
create index on orders(customerid);
drop table if exists product;
create table product (
sku text,
description text,
wholesale_cost decimal
);
\copy product from 'noahs-products.csv' with csv header
create index on product(sku);
drop table if exists order_item;
create table order_item (
orderid int,
sku text,
qty int,
unit_price decimal
);
\copy order_item from 'noahs-orders_items.csv' with csv header
create index on order_item(orderid);
create index on order_item(sku);
commit;