CREATE DOMAIN <Domain name> [ AS ] <data type> [ [NOT] NULL ]
DDL metadata for domains
Domains are simple type declarations that define a set of valid values for a given type name. They can be created at the database level only.
The domain name may any non-keyword identifier.
See the BNF for Data Types
Once a domain is defined it may be referenced as the data type for a column, parameter, etc.
Example: Virtual database DDL
CREATE DOMAIN mychar AS VARCHAR(1000); CREATE VIRTUAL SCHEMA viewLayer; SET SCHEMA viewLayer; CREATE VIEW v1 (col1 mychar) as select 'value'; ...
When the system metadata is queried, the type for the column is shown as the domain name.
Domain names might not be recognized in the following places where a data type is expected:
create temp table
When you query a pg_attribute, the ODBC/pg metadata will show the name of the base type, rather than the domain name.