CREATE DOMAIN statement
434
NULL By default, domains allow NULLs unless the
allow_nulls_by_default option is set to OFF. In this case, new domains by
default do not allow NULLs. The nullability of a column created on a
domain depends on the setting of the definition of the domain, not on the
setting of the allow_nulls_by_default option when the column is referenced.
Any explicit setting of NULL or NOT NULL in the column definition
overrides the domain setting.
CHECK clause When creating a CHECK condition, you can use a
variable name prefixed with the @ sign in the condition. When the data type
is used in the definition of a column, such a variable is replaced by the
column name. This allows CHECK conditions to be defined on data types
and used by columns of any name.
♦
SQL/92 Intermediate level feature.
♦
Sybase Not supported by Adaptive Server Enterprise. Transact-SQL
provides similar functionality using the
sp_addtype
system procedure
and the CREATE DEFAULT and CREATE RULE statements.
♦ The following statement creates a data type named address, which holds
a 35-character string, and which may be NULL.
CREATE DOMAIN address CHAR( 35 ) NULL
♦ The following statement creates a data type named id, which does not
allow NULLS, and which is autoincremented by default.
CREATE DOMAIN id INT
NOT NULL
DEFAULT AUTOINCREMENT
Standards and
compatibility
Example