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_catalog.pg_namespace n ON n.oid = t.typnamespace;
You can list the data type via
\dT+ channels
https://www.postgresql.org/docs/current/static/app-psql.html#APP-PSQL-META-COMMANDS
select enum_range(null::my_enum)
where my_enum
is the enum type name.
Documentation: http://www.postgresql.org/docs/9.5/static/functions-enum.html
This: SELECT unnest(enum_range(NULL::myenum))
returns enum types as rows.
I always forget how to do this. As per the other answer and the comment, here it is a comma-separated list. I like copy-paste snippets. Thanks for the help:
select n.nspname as enum_schema,
t.typname as enum_name,
string_agg(e.enumlabel, ', ') as enum_value
from pg_type t
join pg_enum e on t.oid = e.enumtypid
join pg_catalog.pg_namespace n ON n.oid = t.typnamespace
group by enum_schema, enum_name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With