Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CREATE DOMAIN

Creates a persistent type name based on a supported built-in type:

CREATE DOMAIN name AS type
  [DEFAULT expression]
  [CONSTRAINT name CHECK (VALUE condition)]
  [NOT NULL]

The domain has its own catalog identity and reuses the base type representation. Domain CHECK constraints are applied when the domain is used by a table.

The supported ALTER DOMAIN actions are RENAME TO, SET DEFAULT, DROP DEFAULT, SET NOT NULL, DROP NOT NULL, ADD CONSTRAINT ... CHECK, and DROP CONSTRAINT; DROP DOMAIN is also supported. A drop is rejected while any column still uses the domain. ALTER DOMAIN does not retroactively change defaults, nullability, or checks already copied to existing columns. COLLATE and nested domains remain future work.