Creates a domain definition.
A domain defines the set of values, character set, collating
sequence, and formatting clause that a column in a table can
have. The CREATE DOMAIN statement specifies the set of values by
associating a data type with a domain name.
There are two ways to specify a domain definition:
o With a domain name, data type, and any combination of the
following optional clauses:
- Default value
- Stored name
- Collating sequence
- Formatting clauses such as EDIT STRING or QUERY HEADER
o With the FROM clause and a repository path name that refers to
a field already defined in the repository
When the CREATE DOMAIN statement executes, SQL adds the domain
definition to the database.
If you attached to the database with the PATHNAME specification,
the domain definition is also added to the repository.
You can refer to a domain instead of an SQL data type in the
CREATE and ALTER TABLE statements, and in formal parameter
declarations in functions and procedures. If the domain has to
change, you need only change that one domain definition (using
the ALTER DOMAIN statement) to change all the tables. This
ability makes it easier to keep applications consistent.
A domain can be referenced in the following locations:
o CREATE, ALTER and DROP DOMAIN statements
o CREATE and ALTER TABLE statements as the data type for a
column
o CREATE and ALTER MODULE statements as the data type of a
routine parameter, or the data type of declared variable
o CREATE FUNCTION statement as the data type of a function
parameter or function result
o CREATE PROCEDURE statement as the data type of a procedure
parameter
o CREATE and ALTER SYNONYM statement as the base object for a
synonym
o as the datatype of a CAST expression
o as a data type of a DECLARE variable statement in interactive
SQL
o as the source in the EDIT USING clause of the SELECT and PRINT
statements in interactive SQL. The EDIT STRING is inherited
from that domain.
Additional Information:
explode
extract