Skip to content

Case

SQLEnumSyntax.typeName

PostgreSQL’s custom user type enumerations.
case typeName

Discussion

PostgreSQL implements enums as one of a few different kinds of user-defined custom data types, which must be created separately before their use in a table. Once created, an enumeration may add new cases and rename existing ones, but may not delete them without deleting the entire custom type.

PostgreSQL example:

CREATE TYPE "fruit" AS ENUM ( 'apple', 'orange', 'banana' );

CREATE TABLE "foo" (
    "id" BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
    "my_fruit" fruit NOT NULL
);