Skip to content

Instantly share code, notes, and snippets.

@ghobadkhan
Last active September 9, 2021 12: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 ghobadkhan/097f89afdcb55637a587d5c45ef3e973 to your computer and use it in GitHub Desktop.
Save ghobadkhan/097f89afdcb55637a587d5c45ef3e973 to your computer and use it in GitHub Desktop.
Lists all stored enums in a human readable format - Postgresql
SELECT
type.typname AS name,
string_agg(enum.enumlabel, '|') AS value
FROM pg_enum AS enum
JOIN pg_type AS type
ON (type.oid = enum.enumtypid)
GROUP BY type.typname;
@ghobadkhan
Copy link
Author

ghobadkhan commented Sep 9, 2021

Example Result

   name    |          value
-----------+-------------------------
 transport | bus|tram|rail|ferry
 weather   | sunny|rainy|cloudy|snow
(2 rows)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment