Domain usage is not limited to column definitions for tables and views. Domains can be used to declare input and output parameters and variables in PSQL code.

    3.9.1. Domain Attributes

    A domain definition contains required and optional attributes. The data type is a required attribute. Optional attributes include:

    • a default value

    • to allow or forbid

    • CHECK constraints

    • character set (for character data types and text BLOB fields)

    Sample domain definition

    See also

    Explicit Data Type Conversion for the description of differences in the data conversion mechanism when domains are specified for the TYPE OF and TYPE OF COLUMN modifiers.

    3.9.2. Domain Override

    While defining a column using a domain, it is possible to override some of the attributes inherited from the domain. Table 3.9 summarises the rules for domain override.

    3.9.3. Creating and Administering Domains

    A domain is created with the DDL statement CREATE DOMAIN.

    Short Syntax

    See also

    in the Data Definition Language (DDL) section.

    Altering a Domain
    • rename the domain

    • change the data type

    • delete the current default value

    • set a new default value

    • add a new constraint

    Short Syntax

    When planning to alter a domain, its dependencies must be taken into account: whether there are table columns, any variables, input and/or output parameters with the type of this domain declared in the PSQL code. If you change domains in haste, without carefully checking them, your code may stop working!

    See also

    in the Data Definition Language (DDL) section.

    Deleting (Dropping) a Domain

    The DDL statement DROP DOMAIN deletes a domain from the database, provided it is not in use by any other database objects.

    Syntax

    Example

    See also