create domain

Create a column domain specification

Syntax

create_domain:
          CREATE DOMAIN domain_name [AS] type_def
          [DEFAULT {constant | CURRENT | NULL | AUTO |
               {CURDATE | CURRENT_DATE} | {CURTIME | CURRENT_TIME} | {CURTS | CURRENT_TIMESTAMP}}]

Description

A "domain" is simply a user-defined and named data type which can then be specified as the data type for columns declared in a CREATE TABLE statement. The CREATE DOMAIN statement must be submitted before any CREATE TABLE statements that reference it.

The name of the domain is specified as the domain_name. The data_type specifies the base type for the domain. A constant value or NULL can be specified as the default.

A constant value or NULL can be specified as the DEFAULT. Note that NULL is the default if no DEFAULT is specified. The DEFAULT CURRENT (and the other CURRENT_* constants) applies only to DATE/TIME data types and DEFAULT AUTO applies only to type GUID/UUID.

Examples

CREATE DOMAIN birth_date AS date;
CREATE DOMAIN gender AS char;
CREATE DOMAIN us_state AS char(2);
CREATE DOMAIN money AS decimal(12,2);

See Also

CREATE TABLE

DROP DOMAIN