Type Enumerations - ORGTYTESPOO/kiradigiasm GitHub Wiki

A Type Enumeration

Used when we want a column value to have a specific value out of a set of values.

A new Type Enumeration is created like this:

This example creates an enumerated type and uses it in a table definition:

CREATE TYPE bug_status AS ENUM ('new', 'open', 'closed');

CREATE TABLE bug (
id serial,
description text,
status **bug_status**
);


You can add new values to Type Enumerations like this:

ALTER TYPE enum_type ADD VALUE 'new_value'; -- appends to list
ALTER TYPE enum_type ADD VALUE 'new_value' BEFORE 'old_value';
ALTER TYPE enum_type ADD VALUE 'new_value' AFTER 'old_value';