A Schema may contain zero or more Domains. An SQL Domain is a named, user-defined set of valid values. Domains are dependent on some Schema — the
A Schema may contain zero or more Domains. An SQL Domain is a named, user-defined set of valid values. Domains are dependent on some Schema — the must be unique within the Schema the Domain belongs to (it may not be the same as any in its Schema either) — and are created, altered and dropped using standard SQL statements. The Objects that may belong to a Domain are known as Domain Constraints; they depend on some Domain.
A Domain is defined by a descriptor that contains six pieces of information:
1. The <Domain name>, qualified by the <Schema name> of the Schema to which it belongs.
2. The Domain's SQL <data type> specification, including its name, length, precision and scale, as applicable.
3. The name of the Character set that the Domain's set of values must belong to (for character string types).
4. The name of the Domain's default Collation. (This is the Collation that may be used to compare a character string Domain's values in the absence of an explicit COLLATE clause.)
5. Whether reference values must be checked and whether <reference scope check action> specifies RESTRICT or SET NULL (for REF types).
6. The Domain's default value (if any).
7. A descriptor for every Constraint that belongs to the Domain.
To create a Domain, use the CREATE DOMAIN
statement (either as a stand-alone SQL statement or within a CREATE SCHEMA
statement). CREATE DOMAIN
specifies the enclosing Schema, names the Domain and identifies the Domain's set of valid values. To change an existing Domain, use the ALTER DOMAIN
statement. To destroy a Domain, use the DROP DOMAIN
statement.
There is a one-to-many association between Domains and Columns: one Domain can be used to identify the set of valid values for multiple Columns.