Enumerated types v16

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

Example

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

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 also significant.

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

For more information on enumerated data types, see PostgreSQL docs.