forked from armollica/qcew-data
-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_db.sh
executable file
·56 lines (52 loc) · 1.79 KB
/
create_db.sh
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
#!/bin/bash
source config.sh
CREATE_QUERY="
CREATE TABLE $TABLE (
area_fips varchar(5),
own_code varchar(1),
industry_code varchar(6),
agglvl_code varchar(2),
size_code varchar(1),
year varchar(4),
qtr varchar(1),
disclosure_code varchar(1),
qtrly_estabs integer,
month1_emplvl integer,
month2_emplvl integer,
month3_emplvl integer,
total_qtrly_wages bigint,
taxable_qtrly_wages bigint,
qtrly_contributions bigint,
avg_wkly_wage integer,
lq_disclosure_code varchar(1),
lq_qtrly_estabs real,
lq_month1_emplvl real,
lq_month2_emplvl real,
lq_month3_emplvl real,
lq_total_qtrly_wages real,
lq_taxable_qtrly_wages real,
lq_qtrly_contributions real,
lq_avg_wkly_wage real,
oty_disclosure_code varchar(1),
oty_qtrly_estabs_chg integer,
oty_qtrly_estabs_pct_chg real,
oty_month1_emplvl_chg integer,
oty_month1_emplvl_pct_chg real,
oty_month2_emplvl_chg integer,
oty_month2_emplvl_pct_chg real,
oty_month3_emplvl_chg integer,
oty_month3_emplvl_pct_chg real,
oty_total_qtrly_wages_chg bigint,
oty_total_qtrly_wages_pct_chg real,
oty_taxable_qtrly_wages_chg bigint,
oty_taxable_qtrly_wages_pct_chg real,
oty_qtrly_contributions_chg bigint,
oty_qtrly_contributions_pct_chg real,
oty_avg_wkly_wage_chg integer,
oty_avg_wkly_wage_pct_chg real
);
CREATE INDEX ${TABLE}_area_fips_index ON $TABLE (area_fips);
CREATE INDEX ${TABLE}_industry_code_index ON $TABLE (industry_code);
CREATE INDEX ${TABLE}_agglvl_code_index ON $TABLE (agglvl_code);
"
$PSQL -q "$DATABASE" -c "$CREATE_QUERY";