Search Shortcut cmd + k | ctrl + k
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

CREATE TYPE defines a new data type available to this duckdb instance. These new types can then be inspected in the duckdb_types table.

Extending these custom types to support custom operators (such as the PostgreSQL && operator) would require C++ development. To do this, create an extension.

About this page

Last modified: 2024-03-02