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
- Labels are limited by NAMEDATALEN, 63 bytes in standard builds.
- Labels live in the
pg_enumsystem catalog.
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
- id: C1 claim: Enum labels are case sensitive. source: S1 evidence: "Enum labels are case sensitive, so 'happy' is not the same as 'HAPPY'."
- id: C2 claim: An enum value occupies four bytes on disk. source: S1 evidence: "An enum value occupies four bytes on disk."
- id: C3 claim: Enum labels are kept in the pg_enum catalog. source: S1 evidence: "are kept in the system catalog pg_enum."
- id: C4 claim: CREATE TYPE registers a new data type for the current database. source: S2 evidence: "CREATE TYPE registers a new data type for use in the current database."
- id: C5 claim: The docs create a bug_status enum. source: S2 evidence: "CREATE TYPE bug_status AS ENUM ('new', 'open', 'closed');"
Sources
- [S1] PostgreSQL: Documentation: 18: 8.7. Enumerated Types. PostgreSQL Global Development Group. https://www.postgresql.org/docs/current/datatype-enum.html . License: PostgreSQL License. Accessed 2026-11-04.
- [S2] PostgreSQL: Documentation: 18: CREATE TYPE. PostgreSQL Global Development Group. https://www.postgresql.org/docs/current/sql-createtype.html . License: PostgreSQL License. Accessed 2026-11-04.
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
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.},
}
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.