How do i query values of an enum in postgresql
Hi i want to use an enum in postgresql as an alternative to making a table, because the values my never change, but i want to be able to retrieve thes开发者_开发知识库e values for an application that might check just in case they do, is there any way the query it to get the values?
SELECT unnest(enum_range(NULL::your_enum))::text AS your_column
This will return a single column result set of the contents of the enum "your_enum" with a column named "your_column" of type text.
See the manual: Functions and Operators / Enum Support Functions You probably want the enum_range(...) function. Alternatively, you could look in the system catalogues: pg_enum
精彩评论