type
DOMAIN
A PostgreSQL domain adds reusable constraints to an underlying type. A domain check does not automatically reject NULL. Example target: PostgreSQL 17. Run in a disposable database; examples need no existing tables.
Formal Syntax & Structure
sql syntaxsql
CREATE DOMAIN name AS base_type [constraints]Working Example
Example Snippetsql
CREATE DOMAIN lab_positive AS INTEGER CHECK (VALUE > 0); SELECT CAST(7 AS lab_positive);