Project

General

Profile

1 8093 aaronmk
SELECT functions.to_global_col_names(:table_str);
2
3 8098 aaronmk
SELECT functions.rename_if_exists($$ALTER TABLE "SUBPLOT" RENAME "SUBPLOT.STATECD"  TO ".STATECD" $$);
4
SELECT functions.rename_if_exists($$ALTER TABLE "SUBPLOT" RENAME "SUBPLOT.UNITCD"   TO ".UNITCD"  $$);
5
SELECT functions.rename_if_exists($$ALTER TABLE "SUBPLOT" RENAME "SUBPLOT.COUNTYCD" TO ".COUNTYCD"$$);
6
SELECT functions.rename_if_exists($$ALTER TABLE "SUBPLOT" RENAME "SUBPLOT.PLOT"     TO ".PLOT"    $$);
7
SELECT functions.rename_if_exists($$ALTER TABLE "SUBPLOT" RENAME "SUBPLOT.INVYR"    TO ".INVYR"   $$);
8
SELECT functions.rename_if_exists($$ALTER TABLE "SUBPLOT" RENAME "SUBPLOT.SUBP"     TO ".SUBP"    $$);
9
10 8110 aaronmk
SELECT functions.set_col_types(:table_str, ARRAY[
11
  ('.STATECD' , 'integer')
12
, ('.UNITCD'  , 'integer')
13
, ('.COUNTYCD', 'integer')
14
, ('.PLOT'    , 'integer')
15
, ('.INVYR'   , 'integer')
16
, ('.SUBP'    , 'integer')
17
]::functions.col_cast[]);
18
19 8130 aaronmk
SELECT functions.create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.ID"     UNIQUE ("SUBPLOT.CN")                                                  $$);
20 8098 aaronmk
SELECT functions.create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.unique" UNIQUE (".STATECD", ".UNITCD", ".COUNTYCD", ".PLOT", ".INVYR", ".SUBP")$$);
21 8111 aaronmk
SELECT functions.cluster_once(:table_str, '"SUBPLOT.unique"');