开发者

How do i query values of an enum in postgresql

开发者 https://www.devze.com 2022-12-10 02:15 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消