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 |
8136
|
aaronmk
|
SELECT functions.set_col_types('"TREE"', ARRAY[
|
9 |
8110
|
aaronmk
|
('.STATECD' , 'integer')
|
10 |
|
|
, ('.UNITCD' , 'integer')
|
11 |
|
|
, ('.COUNTYCD', 'integer')
|
12 |
|
|
, ('.PLOT' , 'integer')
|
13 |
|
|
, ('.INVYR' , 'integer')
|
14 |
|
|
, ('.SUBP' , 'integer')
|
15 |
|
|
, ('.CONDID' , 'integer')
|
16 |
|
|
, ('.SPCD' , 'integer')
|
17 |
|
|
]::functions.col_cast[]);
|
18 |
|
|
|
19 |
8128
|
aaronmk
|
-- ("STATECD", "UNITCD", "COUNTYCD", "PLOT", "INVYR", "CONDID", "SUBP", "TREE", "STATUSCD") is not ID
|
20 |
|
|
SELECT functions.create_if_not_exists($$ALTER TABLE "TREE" ADD CONSTRAINT "TREE.ID" UNIQUE ("TREE.CN")$$);
|
21 |
8136
|
aaronmk
|
SELECT functions.cluster_once('"TREE"', '"TREE.ID"');
|
22 |
8099
|
aaronmk
|
|
23 |
|
|
SELECT functions.create_if_not_exists($$CREATE INDEX "TREE.parent" ON "TREE" (".STATECD", ".UNITCD", ".COUNTYCD", ".PLOT", ".INVYR", ".CONDID", ".SUBP")$$);
|