Skip to content

Instantly share code, notes, and snippets.

@clhenrick
Last active August 29, 2015 14:04
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 clhenrick/13f6cfd8dab745948e4c to your computer and use it in GitHub Desktop.
Save clhenrick/13f6cfd8dab745948e4c to your computer and use it in GitHub Desktop.
split column into rows
-- split the name_alt column into new rows using `|` as a delimiter and insert into global_province_synonyms table as new rows
-- to do: do a `IS NOT null` check?
-- note: you have to escape the | character as it is reserved in Postgres
INSERT INTO global_province_synonyms (name, rank, woe_id, country_iso3)
SELECT
regexp_split_to_table(global_province_polygons.name_alt, E'\\|' ) AS name,
1, woe_id, iso3
FROM
global_province_polygons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment