Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14

CREATE DOMAIN

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The CREATE DOMAIN statement allows for creating DOMAIN types for use as data types in table columns.

Depending on the dialect, a DOMAIN combines the following features:

  • A qualified name
  • A base data type
  • A DEFAULT value
  • A NOT NULL constraint
  • A COLLATION
  • A set of CHECK constraints

Domains can be created in jOOQ using:

// Create a domain on a base type
create.createDomain("d1").as(INTEGER).execute();

// Create a domain on a base type and add a DEFAULT expression
create.createDomain("d2").as(INTEGER).default_(1).execute();

// Create a domain on a base type and add a CHECK constraint
create.createDomain("d3").as(INTEGER).constraints(check(value(INTEGER).gt(0))).execute();

Dialect support

This example using jOOQ:

createDomain("d").as(INTEGER)

Translates to the following dialect specific expressions:

Aurora Postgres, H2, HSQLDB, Postgres, YugabyteDB

CREATE DOMAIN d AS int

Firebird

CREATE DOMAIN d AS integer

Oracle

CREATE DOMAIN d AS number(10)

SQLServer

CREATE TYPE d FROM int

ASE, Access, Aurora MySQL, BigQuery, CockroachDB, DB2, Derby, DuckDB, Exasol, Hana, Informix, MariaDB, MemSQL, MySQL, Redshift, SQLDataWarehouse, SQLite, Snowflake, Sybase, Teradata, Trino, Vertica

/* UNSUPPORTED */

(These are currently generated with jOOQ 3.20, see #10141), or translate your own on our website

References to this page

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo