Project

General

Profile

1
SELECT functions.to_global_col_names(:table_str);
2

    
3
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
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
SELECT functions.create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.ID"     UNIQUE ("SUBPLOT.CN")                                                  $$);
20
SELECT functions.create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.unique" UNIQUE (".STATECD", ".UNITCD", ".COUNTYCD", ".PLOT", ".INVYR", ".SUBP")$$);
21
SELECT functions.cluster_once(:table_str, '"SUBPLOT.unique"');
    (1-1/1)