← All notes

PostgreSQL enum types

Answer: An enum type is a fixed, ordered list of text labels created with CREATE TYPE name AS ENUM (...). Values sort in declaration order, take four bytes on disk, and labels are case sensitive.

CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
CREATE TABLE person (name text, current_mood mood);
INSERT INTO person VALUES ('Moe', 'happy');
SELECT * FROM person WHERE current_mood > 'sad';

Facts

Changing an enum

ALTER TYPE mood ADD VALUE 'ecstatic' AFTER 'happy';
ALTER TYPE mood RENAME VALUE 'ok' TO 'fine';

Removing a value is not supported directly.

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 8.7. Enumerated Types, PostgreSQL License; PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: CREATE TYPE, PostgreSQL License.

Cite this

Permanent ID: iil:note:4pn78hj0

iinventedlight. 2026. "PostgreSQL enum types." iinventedlight Library, iil:note:4pn78hj0, version of 2026-11-04. https://iinventedlight.com/library/notes/postgres-enum-types/. License: CC-BY-4.0.

@misc{iil_note_4pn78hj0,
  author = {{iinventedlight}},
  title = {{PostgreSQL enum types}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/postgres-enum-types/},
  note = {Permanent ID iil:note:4pn78hj0. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/postgres-enum-types.md.