Skip to content

Instantly share code, notes, and snippets.

@luiz
Created February 2, 2026 19:12
Show Gist options
  • Select an option

  • Save luiz/abae946a34604cbd39324d6c0f4f2b22 to your computer and use it in GitHub Desktop.

Select an option

Save luiz/abae946a34604cbd39324d6c0f4f2b22 to your computer and use it in GitHub Desktop.
Get enum type allowed values (Postgres)
SELECT
n.nspname AS enum_schema,
t.typname AS enum_name,
e.enumlabel AS enum_value
FROM
pg_type t
JOIN
pg_enum e ON t.oid = e.enumtypid
JOIN
pg_namespace n ON n.oid = t.typnamespace
WHERE
t.typtype = 'e' -- Filters for ENUM types
AND t.typname = 'XXXXX' -- replace here
ORDER BY
enum_schema, enum_name, e.enumsortorder;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment