Revision 10084
Added by Aaron Marcuse-Kubitza over 11 years ago
inputs/FIA/PLOT/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
SELECT set_col_types('"PLOT"', ARRAY[ |
|
9 |
('*STATECD', 'integer') |
|
10 |
, ('*UNITCD', 'integer') |
|
11 |
, ('*COUNTYCD', 'integer') |
|
12 |
, ('locationName', 'integer') |
|
13 |
, ('*INVYR', 'integer') |
|
14 |
]::col_cast[]); |
|
15 |
|
|
16 |
SELECT create_if_not_exists($$ALTER TABLE "PLOT" ADD CONSTRAINT "PLOT.ID" UNIQUE ("locationID")$$); |
|
17 |
SELECT create_if_not_exists($$ALTER TABLE "PLOT" ADD CONSTRAINT "PLOT.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR")$$); |
|
18 |
SELECT cluster_once('"PLOT"', '"PLOT.unique"'); |
|
19 |
EOF |
|
20 |
mk_derived |
|
21 | 0 |
inputs/FIA/COUNTY/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
SELECT set_col_types('"COUNTY"', ARRAY[ |
|
9 |
('*STATECD', 'integer') |
|
10 |
, ('*UNITCD', 'integer') |
|
11 |
, ('*COUNTYCD', 'integer') |
|
12 |
]::col_cast[]); |
|
13 |
|
|
14 |
SELECT create_if_not_exists($$ALTER TABLE "COUNTY" ADD CONSTRAINT "COUNTY.ID" UNIQUE ("*COUNTY-CN")$$); |
|
15 |
SELECT create_if_not_exists($$ALTER TABLE "COUNTY" ADD CONSTRAINT "COUNTY.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD")$$); |
|
16 |
EOF |
|
17 |
mk_derived |
|
18 | 0 |
inputs/FIA/REF_PLANT_DICTIONARY/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
-- Remove 56 duplicate symbols of type 'Old' (these are ambiguous) |
|
9 |
DELETE FROM "REF_PLANT_DICTIONARY" |
|
10 |
WHERE "*PLANT_SYMBOL" IN ( |
|
11 |
SELECT "*PLANT_SYMBOL" |
|
12 |
FROM "REF_PLANT_DICTIONARY" |
|
13 |
WHERE "*PLANT_SYMBOL_TYPE" = 'Old' |
|
14 |
GROUP BY "*PLANT_SYMBOL" |
|
15 |
HAVING count(*) > 1 |
|
16 |
); |
|
17 |
|
|
18 |
SELECT create_if_not_exists($$ALTER TABLE "REF_PLANT_DICTIONARY" ADD CONSTRAINT "REF_PLANT_DICTIONARY.unique" UNIQUE ("*PLANT_SYMBOL_TYPE", "*PLANT_SYMBOL")$$); |
|
19 |
EOF |
|
20 |
mk_derived |
|
21 | 0 |
inputs/FIA/REF_UNIT/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
SELECT set_col_types('"REF_UNIT"', ARRAY[ |
|
9 |
('*STATECD', 'integer') |
|
10 |
, ('*UNITCD', 'integer') |
|
11 |
]::col_cast[]); |
|
12 |
|
|
13 |
SELECT create_if_not_exists($$ALTER TABLE "REF_UNIT" ADD CONSTRAINT "REF_UNIT.unique" UNIQUE ("*STATECD", "*UNITCD")$$); |
|
14 |
EOF |
|
15 |
mk_derived |
|
16 | 0 |
inputs/FIA/COND/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
SELECT set_col_types('"COND"', ARRAY[ |
|
9 |
('*STATECD', 'integer') |
|
10 |
, ('*UNITCD', 'integer') |
|
11 |
, ('*COUNTYCD', 'integer') |
|
12 |
, ('locationName', 'integer') |
|
13 |
, ('*INVYR', 'integer') |
|
14 |
, ('authorEventCode', 'integer') |
|
15 |
]::col_cast[]); |
|
16 |
|
|
17 |
SELECT mk_derived_col(('"COND"', 'oldGrowth'), $$ |
|
18 |
( |
|
19 |
"*COND-STDAGE"::integer>80 |
|
20 |
AND ("*COND-TRTCD1"='0' OR "*COND-TRTCD1" IS NULL) |
|
21 |
AND (("*COND-DSTRBCD1"<>'30' AND "*COND-DSTRBCD1"<>'31' AND "*COND-DSTRBCD1"<>'32' AND "*COND-DSTRBCD1"<>'80') OR "*COND-DSTRBCD1" IS NULL) |
|
22 |
AND ("*COND-STUMP_CD_PNWRS"='N' OR "*COND-STUMP_CD_PNWRS" IS NULL) |
|
23 |
AND "*COND-HARVEST_TYPE1_SRS" IS NULL |
|
24 |
AND "*COND-PRESNFCD" IS NULL |
|
25 |
AND ("*COND-STDORGCD"='0' OR "*COND-STDORGCD" IS NULL) |
|
26 |
) |
|
27 |
OR "*COND-STND_COND_CD_PNWRS"='7' |
|
28 |
$$); |
|
29 |
|
|
30 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.ID" UNIQUE ("*COND-CN")$$); |
|
31 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "authorEventCode")$$); |
|
32 |
SELECT cluster_once('"COND"', '"COND.unique"'); |
|
33 |
EOF |
|
34 |
mk_derived |
|
35 | 0 |
inputs/FIA/REF_SPECIES/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
SELECT set_col_types('"REF_SPECIES"', ARRAY[ |
|
9 |
('*SPCD', 'integer') |
|
10 |
]::col_cast[]); |
|
11 |
|
|
12 |
SELECT mk_const_col(('"REF_SPECIES"', '*PLANT_SYMBOL_TYPE'), 'Species'::text); |
|
13 |
|
|
14 |
SELECT create_if_not_exists($$ALTER TABLE "REF_SPECIES" ADD CONSTRAINT "REF_SPECIES.unique" UNIQUE ("*SPCD")$$); |
|
15 |
EOF |
|
16 |
mk_derived |
|
17 | 0 |
inputs/FIA/TREE/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
SELECT set_col_types('"TREE"', ARRAY[ |
|
9 |
('*STATECD', 'integer') |
|
10 |
, ('*UNITCD', 'integer') |
|
11 |
, ('*COUNTYCD', 'integer') |
|
12 |
, ('locationName', 'integer') |
|
13 |
, ('*INVYR', 'integer') |
|
14 |
, ('subplot', 'integer') |
|
15 |
, ('authorEventCode', 'integer') |
|
16 |
, ('*SPCD', 'integer') |
|
17 |
]::col_cast[]); |
|
18 |
|
|
19 |
-- ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "authorEventCode", "subplot", "*TREE", "*STATUSCD") is not ID |
|
20 |
SELECT create_if_not_exists($$ALTER TABLE "TREE" ADD CONSTRAINT "TREE.ID" UNIQUE ("individualObservationID")$$); |
|
21 |
|
|
22 |
SELECT create_if_not_exists($$CREATE INDEX "TREE.parent" ON "TREE" ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "authorEventCode", "subplot")$$); |
|
23 |
SELECT cluster_once('"TREE"', '"TREE.parent"'); |
|
24 |
EOF |
|
25 |
mk_derived |
|
26 | 0 |
inputs/FIA/occurrence_all/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
export new_term_prefix= # don't re-prepend * |
|
7 |
|
|
8 |
psql <<'EOF' |
|
9 |
SELECT force_update_view('"occurrence_all"', $$ |
|
10 |
SELECT "*TREE-row_num" AS "occurrence_all-row_num", * |
|
11 |
/* directional joins ensure that the PostgreSQL query planner always joins |
|
12 |
starting with the TREE table */ |
|
13 |
FROM ("REF_RESEARCH_STATION" |
|
14 |
NATURAL RIGHT JOIN ("REF_UNIT" |
|
15 |
NATURAL RIGHT JOIN ("COUNTY" |
|
16 |
NATURAL RIGHT JOIN ("PLOT" |
|
17 |
NATURAL RIGHT JOIN ("COND" |
|
18 |
NATURAL LEFT JOIN "REF_HABTYP_DESCRIPTION" |
|
19 |
NATURAL RIGHT JOIN ("SUBPLOT" |
|
20 |
NATURAL RIGHT JOIN ("TREE" |
|
21 |
NATURAL LEFT JOIN "REF_SPECIES" |
|
22 |
NATURAL LEFT JOIN "REF_PLANT_DICTIONARY" |
|
23 |
))))))) |
|
24 |
$$); |
|
25 |
|
|
26 |
SELECT mk_subset_by_row_num_func('"occurrence_all"', 'occurrence_all-row_num'); |
|
27 |
EOF |
|
28 |
|
|
29 |
remake_VegBIEN_mappings |
|
30 | 0 |
inputs/FIA/REF_HABTYP_DESCRIPTION/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
SELECT create_if_not_exists($$ALTER TABLE "REF_HABTYP_DESCRIPTION" ADD CONSTRAINT "REF_HABTYP_DESCRIPTION.unique" UNIQUE ("*HABTYPCD", "*HABTYP_PUB_CD")$$); |
|
9 |
EOF |
|
10 |
mk_derived |
|
11 | 0 |
inputs/FIA/SUBPLOT/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
SELECT set_col_types('"SUBPLOT"', ARRAY[ |
|
9 |
('*STATECD', 'integer') |
|
10 |
, ('*UNITCD', 'integer') |
|
11 |
, ('*COUNTYCD', 'integer') |
|
12 |
, ('locationName', 'integer') |
|
13 |
, ('*INVYR', 'integer') |
|
14 |
, ('subplot', 'integer') |
|
15 |
]::col_cast[]); |
|
16 |
|
|
17 |
SELECT create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.ID" UNIQUE ("subplotID")$$); |
|
18 |
SELECT create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "subplot")$$); |
|
19 |
SELECT cluster_once('"SUBPLOT"', '"SUBPLOT.unique"'); |
|
20 |
EOF |
|
21 |
mk_derived |
|
22 | 0 |
inputs/FIA/REF_RESEARCH_STATION/import | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# :mode=transact-sql: |
|
3 |
cd "$(dirname "$0")" |
|
4 |
. ../../../lib/import.sh |
|
5 |
|
|
6 |
map_table |
|
7 |
psql <<'EOF' |
|
8 |
-- contains the research station *and state name* for each state |
|
9 |
|
|
10 |
SELECT set_col_types('"REF_RESEARCH_STATION"', ARRAY[ |
|
11 |
('*STATECD', 'integer') |
|
12 |
]::col_cast[]); |
|
13 |
|
|
14 |
SELECT create_if_not_exists($$ALTER TABLE "REF_RESEARCH_STATION" ADD CONSTRAINT "REF_RESEARCH_STATION.unique" UNIQUE ("*STATECD")$$); |
|
15 |
EOF |
|
16 |
mk_derived |
|
17 | 0 |
inputs/FIA/PLOT/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT set_col_types('"PLOT"', ARRAY[ |
|
4 |
('*STATECD', 'integer') |
|
5 |
, ('*UNITCD', 'integer') |
|
6 |
, ('*COUNTYCD', 'integer') |
|
7 |
, ('locationName', 'integer') |
|
8 |
, ('*INVYR', 'integer') |
|
9 |
]::col_cast[]); |
|
10 |
|
|
11 |
SELECT create_if_not_exists($$ALTER TABLE "PLOT" ADD CONSTRAINT "PLOT.ID" UNIQUE ("locationID")$$); |
|
12 |
SELECT create_if_not_exists($$ALTER TABLE "PLOT" ADD CONSTRAINT "PLOT.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR")$$); |
|
13 |
SELECT cluster_once('"PLOT"', '"PLOT.unique"'); |
|
0 | 14 |
inputs/FIA/COUNTY/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT set_col_types('"COUNTY"', ARRAY[ |
|
4 |
('*STATECD', 'integer') |
|
5 |
, ('*UNITCD', 'integer') |
|
6 |
, ('*COUNTYCD', 'integer') |
|
7 |
]::col_cast[]); |
|
8 |
|
|
9 |
SELECT create_if_not_exists($$ALTER TABLE "COUNTY" ADD CONSTRAINT "COUNTY.ID" UNIQUE ("*COUNTY-CN")$$); |
|
10 |
SELECT create_if_not_exists($$ALTER TABLE "COUNTY" ADD CONSTRAINT "COUNTY.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD")$$); |
|
0 | 11 |
inputs/FIA/REF_PLANT_DICTIONARY/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
-- Remove 56 duplicate symbols of type 'Old' (these are ambiguous) |
|
4 |
DELETE FROM "REF_PLANT_DICTIONARY" |
|
5 |
WHERE "*PLANT_SYMBOL" IN ( |
|
6 |
SELECT "*PLANT_SYMBOL" |
|
7 |
FROM "REF_PLANT_DICTIONARY" |
|
8 |
WHERE "*PLANT_SYMBOL_TYPE" = 'Old' |
|
9 |
GROUP BY "*PLANT_SYMBOL" |
|
10 |
HAVING count(*) > 1 |
|
11 |
); |
|
12 |
|
|
13 |
SELECT create_if_not_exists($$ALTER TABLE "REF_PLANT_DICTIONARY" ADD CONSTRAINT "REF_PLANT_DICTIONARY.unique" UNIQUE ("*PLANT_SYMBOL_TYPE", "*PLANT_SYMBOL")$$); |
|
0 | 14 |
inputs/FIA/REF_UNIT/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT set_col_types('"REF_UNIT"', ARRAY[ |
|
4 |
('*STATECD', 'integer') |
|
5 |
, ('*UNITCD', 'integer') |
|
6 |
]::col_cast[]); |
|
7 |
|
|
8 |
SELECT create_if_not_exists($$ALTER TABLE "REF_UNIT" ADD CONSTRAINT "REF_UNIT.unique" UNIQUE ("*STATECD", "*UNITCD")$$); |
|
0 | 9 |
inputs/FIA/COND/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT set_col_types('"COND"', ARRAY[ |
|
4 |
('*STATECD', 'integer') |
|
5 |
, ('*UNITCD', 'integer') |
|
6 |
, ('*COUNTYCD', 'integer') |
|
7 |
, ('locationName', 'integer') |
|
8 |
, ('*INVYR', 'integer') |
|
9 |
, ('authorEventCode', 'integer') |
|
10 |
]::col_cast[]); |
|
11 |
|
|
12 |
SELECT mk_derived_col(('"COND"', 'oldGrowth'), $$ |
|
13 |
( |
|
14 |
"*COND-STDAGE"::integer>80 |
|
15 |
AND ("*COND-TRTCD1"='0' OR "*COND-TRTCD1" IS NULL) |
|
16 |
AND (("*COND-DSTRBCD1"<>'30' AND "*COND-DSTRBCD1"<>'31' AND "*COND-DSTRBCD1"<>'32' AND "*COND-DSTRBCD1"<>'80') OR "*COND-DSTRBCD1" IS NULL) |
|
17 |
AND ("*COND-STUMP_CD_PNWRS"='N' OR "*COND-STUMP_CD_PNWRS" IS NULL) |
|
18 |
AND "*COND-HARVEST_TYPE1_SRS" IS NULL |
|
19 |
AND "*COND-PRESNFCD" IS NULL |
|
20 |
AND ("*COND-STDORGCD"='0' OR "*COND-STDORGCD" IS NULL) |
|
21 |
) |
|
22 |
OR "*COND-STND_COND_CD_PNWRS"='7' |
|
23 |
$$); |
|
24 |
|
|
25 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.ID" UNIQUE ("*COND-CN")$$); |
|
26 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "authorEventCode")$$); |
|
27 |
SELECT cluster_once('"COND"', '"COND.unique"'); |
|
0 | 28 |
inputs/FIA/REF_SPECIES/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT set_col_types('"REF_SPECIES"', ARRAY[ |
|
4 |
('*SPCD', 'integer') |
|
5 |
]::col_cast[]); |
|
6 |
|
|
7 |
SELECT mk_const_col(('"REF_SPECIES"', '*PLANT_SYMBOL_TYPE'), 'Species'::text); |
|
8 |
|
|
9 |
SELECT create_if_not_exists($$ALTER TABLE "REF_SPECIES" ADD CONSTRAINT "REF_SPECIES.unique" UNIQUE ("*SPCD")$$); |
|
0 | 10 |
inputs/FIA/TREE/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT set_col_types('"TREE"', ARRAY[ |
|
4 |
('*STATECD', 'integer') |
|
5 |
, ('*UNITCD', 'integer') |
|
6 |
, ('*COUNTYCD', 'integer') |
|
7 |
, ('locationName', 'integer') |
|
8 |
, ('*INVYR', 'integer') |
|
9 |
, ('subplot', 'integer') |
|
10 |
, ('authorEventCode', 'integer') |
|
11 |
, ('*SPCD', 'integer') |
|
12 |
]::col_cast[]); |
|
13 |
|
|
14 |
-- ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "authorEventCode", "subplot", "*TREE", "*STATUSCD") is not ID |
|
15 |
SELECT create_if_not_exists($$ALTER TABLE "TREE" ADD CONSTRAINT "TREE.ID" UNIQUE ("individualObservationID")$$); |
|
16 |
|
|
17 |
SELECT create_if_not_exists($$CREATE INDEX "TREE.parent" ON "TREE" ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "authorEventCode", "subplot")$$); |
|
18 |
SELECT cluster_once('"TREE"', '"TREE.parent"'); |
|
0 | 19 |
inputs/FIA/occurrence_all/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT force_update_view('"occurrence_all"', $$ |
|
4 |
SELECT "*TREE-row_num" AS "occurrence_all-row_num", * |
|
5 |
/* directional joins ensure that the PostgreSQL query planner always joins |
|
6 |
starting with the TREE table */ |
|
7 |
FROM ("REF_RESEARCH_STATION" |
|
8 |
NATURAL RIGHT JOIN ("REF_UNIT" |
|
9 |
NATURAL RIGHT JOIN ("COUNTY" |
|
10 |
NATURAL RIGHT JOIN ("PLOT" |
|
11 |
NATURAL RIGHT JOIN ("COND" |
|
12 |
NATURAL LEFT JOIN "REF_HABTYP_DESCRIPTION" |
|
13 |
NATURAL RIGHT JOIN ("SUBPLOT" |
|
14 |
NATURAL RIGHT JOIN ("TREE" |
|
15 |
NATURAL LEFT JOIN "REF_SPECIES" |
|
16 |
NATURAL LEFT JOIN "REF_PLANT_DICTIONARY" |
|
17 |
))))))) |
|
18 |
$$); |
|
19 |
|
|
20 |
SELECT mk_subset_by_row_num_func('"occurrence_all"', 'occurrence_all-row_num'); |
|
0 | 21 |
inputs/FIA/REF_HABTYP_DESCRIPTION/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT create_if_not_exists($$ALTER TABLE "REF_HABTYP_DESCRIPTION" ADD CONSTRAINT "REF_HABTYP_DESCRIPTION.unique" UNIQUE ("*HABTYPCD", "*HABTYP_PUB_CD")$$); |
|
0 | 4 |
inputs/FIA/SUBPLOT/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
SELECT set_col_types('"SUBPLOT"', ARRAY[ |
|
4 |
('*STATECD', 'integer') |
|
5 |
, ('*UNITCD', 'integer') |
|
6 |
, ('*COUNTYCD', 'integer') |
|
7 |
, ('locationName', 'integer') |
|
8 |
, ('*INVYR', 'integer') |
|
9 |
, ('subplot', 'integer') |
|
10 |
]::col_cast[]); |
|
11 |
|
|
12 |
SELECT create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.ID" UNIQUE ("subplotID")$$); |
|
13 |
SELECT create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "subplot")$$); |
|
14 |
SELECT cluster_once('"SUBPLOT"', '"SUBPLOT.unique"'); |
|
0 | 15 |
inputs/FIA/REF_RESEARCH_STATION/postprocess.sql | ||
---|---|---|
1 |
SELECT util.search_path_append('util'); |
|
2 |
|
|
3 |
-- contains the research station *and state name* for each state |
|
4 |
|
|
5 |
SELECT set_col_types('"REF_RESEARCH_STATION"', ARRAY[ |
|
6 |
('*STATECD', 'integer') |
|
7 |
]::col_cast[]); |
|
8 |
|
|
9 |
SELECT create_if_not_exists($$ALTER TABLE "REF_RESEARCH_STATION" ADD CONSTRAINT "REF_RESEARCH_STATION.unique" UNIQUE ("*STATECD")$$); |
|
0 | 10 |
Also available in: Unified diff
inputs/FIA/*/import: changed to postprocess.sql for use by the runscripts