postgresql_16:3.5.7.1 Declaration of Enumerated Types
PostgreSQL 16 > The SQL Language > Data Types > Enumerated Types > Declaration of Enumerated Types
Enum types are created using the (see postgresql_16:7.1.92) command, for example: CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy'); Once created, the enum type can be used in table and function definitions much like any other type: 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 = 'happy'; name | current_mood ------+-------------- Moe | happy (1 row)