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
|