TIL enum_range returns all the values in a PostgreSQL enum

Oliver Peate posted on June 14th, 2019

Given an enum called direction, the following query:

SELECT unnest(enum_range(null::direction)) AS directions;

Provides a row per enum value:

directions
----------
north
east
south
west

References:

What did you learn today?

Write a quick TIL post to reflect on what you've learned.

Write a post