Enumerated types v16

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


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;
  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.