Creating Domains (Data Definition Guide)

From InterBase
Jump to: navigation, search

Go Up to Working with Domains


When you create a table, you can use a global column definition, called a domain, to define a column locally. Before defining a column that references a domain, you must first create the domain definition in the database with CREATE DOMAIN. CREATE DOMAIN acts as a template for defining columns in subsequent CREATE TABLE and ALTER TABLE statements. For more information on creating and modifying tables, see Working with Tables.

Domains are useful when many tables in a database contain identical column definitions. Columns based on a domain definition inherit all characteristics of the domain; some of these attributes can be overridden by local column definitions.

Note

You cannot apply referential integrity constraints to a domain.

When you create a domain in the database, you must specify a unique name for the domain and specify the data type. Optionally, you provide default values and NULL status, CHECK constraints, and a collation order.

The syntax for CREATE DOMAIN is:

CREATE DOMAIN domain [AS] <data_type>
 [DEFAULT {literal
| NULL | USER}]
 [NOT NULL] [CHECK (<dom_search_condition>)]
 [COLLATE collation];

Topics

Advance To: