列出Postgres ENUM类型 [英] list Postgres ENUM type

查看:81
本文介绍了列出Postgres ENUM类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

建议查询以列出ENUM类型是很棒的。但是,它仅列出 schema typname 。如何列出实际的ENUM值?例如,在上面的链接答案中,我想要以下结果

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'


推荐答案

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

这篇关于列出Postgres ENUM类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆