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 DDL for domains is common to both XML and DDL VDBs. However in an XML vdb domains must be defined in a VDB property "domain-ddl".
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';
...
Example: XML VDB
<vdb name="Portfolio" version="1">
<property name="domain-ddl" value="CREATE DOMAIN ssn AS VARCHAR(9); CREATE DOMAIN myint AS integer not null;" />
...
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
-
execute immediate
-
arraytable
-
objecttable
-
texttable
-
xmltable
When you query a pg_attribute, the ODBC/pg metadata will show the name of the base type, rather than the domain name.