list Postgres ENUM type

前端 未结 9 2210
一个人的身影
一个人的身影 2020-12-12 11:57

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

9条回答
  •  误落风尘
    2020-12-12 12:22

    @dpb:

    If you want to create a permanent easy access method for this, you could always create a view

    CREATE OR REPLACE VIEW oublic.enumz AS 
     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;
    

    You could then create a trigger for the insert command.

    The above will store this in the database for future reference purposes.

提交回复
热议问题