Revision 8316
Added by Aaron Marcuse-Kubitza over 11 years ago
import | ||
---|---|---|
16 | 16 |
|
17 | 17 |
SELECT mk_derived_col(('"COND"', 'oldGrowth'), $$ |
18 | 18 |
( |
19 |
"COND |
|
20 |
STDAGE"::integer>80 |
|
21 |
AND ("COND |
|
22 |
TRTCD1"='0' OR "COND |
|
23 |
TRTCD1" IS NULL) |
|
24 |
AND (("COND |
|
25 |
DSTRBCD1"<>'30' AND "COND |
|
26 |
DSTRBCD1"<>'31' AND "COND |
|
27 |
DSTRBCD1"<>'32' AND "COND |
|
28 |
DSTRBCD1"<>'80') OR "COND |
|
29 |
DSTRBCD1" IS NULL) |
|
30 |
AND ("COND |
|
31 |
STUMP_CD_PNWRS"='N' OR "COND |
|
32 |
STUMP_CD_PNWRS" IS NULL) |
|
33 |
AND "COND |
|
34 |
HARVEST_TYPE1_SRS" IS NULL |
|
35 |
AND "COND |
|
36 |
PRESNFCD" IS NULL |
|
37 |
AND ("COND |
|
38 |
STDORGCD"='0' OR "COND |
|
39 |
STDORGCD" IS NULL) |
|
19 |
"COND-STDAGE"::integer>80 |
|
20 |
AND ("COND-TRTCD1"='0' OR "COND-TRTCD1" IS NULL) |
|
21 |
AND (("COND-DSTRBCD1"<>'30' AND "COND-DSTRBCD1"<>'31' AND "COND-DSTRBCD1"<>'32' AND "COND-DSTRBCD1"<>'80') OR "COND-DSTRBCD1" IS NULL) |
|
22 |
AND ("COND-STUMP_CD_PNWRS"='N' OR "COND-STUMP_CD_PNWRS" IS NULL) |
|
23 |
AND "COND-HARVEST_TYPE1_SRS" IS NULL |
|
24 |
AND "COND-PRESNFCD" IS NULL |
|
25 |
AND ("COND-STDORGCD"='0' OR "COND-STDORGCD" IS NULL) |
|
40 | 26 |
) |
41 |
OR "COND |
|
42 |
STND_COND_CD_PNWRS"='7' |
|
27 |
OR "COND-STND_COND_CD_PNWRS"='7' |
|
43 | 28 |
$$); |
44 | 29 |
|
45 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.ID" UNIQUE ("COND |
|
46 |
CN")$$); |
|
30 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.ID" UNIQUE ("COND-CN")$$); |
|
47 | 31 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.unique" UNIQUE ("STATECD", "UNITCD", "COUNTYCD", "locationName", "INVYR", "authorEventCode")$$); |
48 | 32 |
SELECT cluster_once('"COND"', '"COND.unique"'); |
49 | 33 |
EOF |
Also available in: Unified diff
inputs/FIA/*/map.csv: Changed newlines between table and field name to - because the newlines mess up the flow of queries and also break pgAdmin's display of EXPLAIN output. The - was chosen because it's a non-whitespace character that linewraps in browsers, phpPgAdmin, and Google spreadsheets (although unfortunately not in pgAdmin). It is better than space because you can set a text editor to treat it as a word character, allowing the entire column name (<table>-<field>) to be selected by double-clicking it.