Skip to main content
A consists of a set of enumerated, static values.

Syntax

To declare a new enumerated data type, use :
where <name is the name of the new type, and <value1, <value2>,... are string literals that make up the type’s set of static values. You can qualify the <name of an enumerated type with a (e.g., db.typename). After the type is created, it can only be referenced from the database that contains the type. To show all ENUM types in the database, including all ENUMS created implicitly for , use :
To modify an ENUM type, use :
where <value is a string literal to add to the existing list of type values. You can also use ALTER TYPE to rename types, rename type values, set a type’s schema, or change the type owner’s . To drop the type, use :

Required privileges

  • To in a database, a user must have the CREATE on the database.
  • To , a user must be the owner of the type.
  • To , a user must be the owner of the type.
  • To on a type, a user must have the GRANT privilege and the privilege that they want to grant.
  • To create an object that depends on a type, a user must have the USAGE privilege on the type.

Example

Supported casting and conversion

ENUM data type values can be to . Values can be cast explicitly or implicitly. For example, the following statements are equivalent:

Comparing enumerated types

To compare two enumerated types, you must explicitly cast both types as STRINGs. For example:

See also