CREATE TYPE Statement
The CREATE TYPE statement defines a new type in the catalog.
Examples
Create a simple ENUM type:
CREATE TYPE mood AS ENUM ('happy', 'sad', 'curious');
Create a simple STRUCT type:
CREATE TYPE many_things AS STRUCT(k INTEGER, l VARCHAR);
Create a simple UNION type:
CREATE TYPE one_thing AS UNION(number INTEGER, string VARCHAR);
Create a type alias:
CREATE TYPE x_index AS INTEGER;
Syntax
The CREATE TYPE clause defines a new data type available to this Goose instance.
These new types can then be inspected in the goose_types table.
Limitations
-
Extending types to support custom operators (such as the PostgreSQL
&&operator) is not possible via plain SQL. Instead, it requires adding additional C++ code. To do this, create an extension. -
The
CREATE TYPEclause does not support theOR REPLACEmodifier.