Available in versions: Dev (3.19) | Latest (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

-- ACCESS, ASE, AURORA_MYSQL, BIGQUERY, COCKROACHDB, DB2, DERBY, DUCKDB, EXASOL, HANA, INFORMIX, MARIADB, MEMSQL, MYSQL, 
-- REDSHIFT, SNOWFLAKE, SQLDATAWAREHOUSE, SQLITE, SYBASE, TERADATA, TRINO, VERTICA
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.19, 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