CREATE TYPE
The CREATE TYPE statement defines a new type in the catalog.
Examples
Create a simple ENUM type:
Query
CREATE TYPE mood AS ENUM ('happy', 'sad', 'curious');Create a simple STRUCT type:
Query
CREATE TYPE many_things AS STRUCT(k INTEGER, l VARCHAR);Create a simple UNION type:
Query
CREATE TYPE one_thing AS UNION(number INTEGER, string VARCHAR);Create a type alias:
Query
CREATE TYPE x_index AS INTEGER;Syntax
The CREATE TYPE clause defines a new data type available to this SereneDB instance.
These new types can then be inspected in the duckdb_types table.
Limitations
-
Extending types to support custom operators (such as the PostgreSQL
&&operator) is not possible via plain SQL. -
The
CREATE TYPEclause does not support theOR REPLACEmodifier.