Skip to content

Instantly share code, notes, and snippets.

@smathermather
Created February 13, 2015 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smathermather/9c2071fab6785ab2fc6f to your computer and use it in GitHub Desktop.
Save smathermather/9c2071fab6785ab2fc6f to your computer and use it in GitHub Desktop.
regexp split to table
CREATE TABLE nr.oram_metrics AS
SELECT oram_id, 'm1_wetland_area'::text AS metric, regexp_split_to_table(m1_wetland_area, ',')::text AS selection
FROM nr.cm_oram_data
UNION ALL
SELECT oram_id, 'm2a_upland_buffer_width'::text AS metric, regexp_split_to_table(m2a_upland_buffer_width, ',')::text AS selection
FROM nr.cm_oram_data;
ALTER TABLE nr.oram_metrics ADD CONSTRAINT "metric_constraint"
FOREIGN KEY (metric, selection) REFERENCES nr.oram_score_lookup_all (metric, selection);​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment