root/inputs/FIA/SUBPLOT/import @ 9812
1 | 8163 | aaronmk | #!/bin/bash
|
---|---|---|---|
2 | # :mode=transact-sql:
|
||
3 | cd "$(dirname "$0")" |
||
4 | . ../../../lib/import.sh
|
||
5 | |||
6 | 8164 | aaronmk | map_table |
7 | 8163 | aaronmk | psql <<'EOF' |
8 | 8184 | aaronmk | SELECT set_col_types('"SUBPLOT"', ARRAY[
|
9 | 8172 | aaronmk | ('STATECD', 'integer')
|
10 | , ('UNITCD', 'integer')
|
||
11 | 8170 | aaronmk | , ('COUNTYCD', 'integer')
|
12 | 8172 | aaronmk | , ('locationName', 'integer')
|
13 | , ('INVYR', 'integer')
|
||
14 | , ('subplot', 'integer')
|
||
15 | 8184 | aaronmk | ]::col_cast[]);
|
16 | 8110 | aaronmk | |
17 | 8184 | aaronmk | 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 | 8208 | aaronmk | EOF
|
21 | mk_derived |