Enumerated types v15

NameNativeAliasDescription
ENUMStatic, ordered set of values, 4 bytes storage. Max length is limited by NAMEDATALEN setting in PostgreSQL.

Example

This example shows how to create ENUM types and use them:

CREATE TYPE city AS ENUM('Pune','Mumbai','Chennai');

CREATE TABLE shops(name text, location city);

INSERT INTO shops VALUES('Puma',`Mumbai` );

SELECT * FROM shops;
Output
  name  |  location
--------+-----------
  Puma  | Mumbai

ENUM types are case sensitive, and whitespace in ENUM types is significant.

The ENUM types and its labels are stored in the pg_enum system catalog.

For more information on enumerated data types, see the PostgreSQL documentation.