Skip to content

Instantly share code, notes, and snippets.

@lene
Last active January 30, 2018 14:40
Show Gist options
  • Save lene/3b03498ef6123ac3f057 to your computer and use it in GitHub Desktop.
Save lene/3b03498ef6123ac3f057 to your computer and use it in GitHub Desktop.
Select a list of all keys in an HSTORE field across the entire table
CREATE TABLE my_hstore_table (
id SERIAL NOT NULL,
attributes HSTORE NOT NULL
);
SELECT DISTINCT UNNEST(AKEYS(attributes)) AS key FROM my_hstore_table ORDER BY key;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment