list Postgres ENUM type Ask Question

list Postgres ENUM type Ask Question

The suggested query to list ENUM types is great. But, it merely lists of the schema and the typname. How do I list out the actual ENUM values? For example, in the linked answer above, I would want the following result

schema         type      values
-------------  --------  -------
communication  channels  'text_message','email','phone_call','broadcast'

ベストアンサー1

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;

おすすめ記事