Search Shortcut cmd + k | ctrl + k
Search cmd+k ctrl+k
0.10 (stable)
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 DuckDB 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. Instead, it requires adding additional C++ code. To do this, create an extension.

About this page

Last modified: 2024-05-17