FirebirdSQL logo
 SHADOWTABLE 

What ALTER DOMAIN Cannot Alter

  • If the domain was declared as an array, it is not possible to change its type or its dimensions;nor can any other type be changed to an array type.

  • The collation cannot be changed without dropping the domain and recreating it with the desired attributes.

Who Can Alter a Domain

The ALTER DOMAIN statement can be executed by:

  • Administrators

  • The owner of the domain

  • Users with the ALTER ANY DOMAIN privilege

Domain alterations can be prevented by dependencies from objects to which the user does not have sufficient privileges.

docnext count = 4

ALTER DOMAIN Examples

  1. Changing the data type to INTEGER and setting or changing the default value to 2,000:

    ALTER DOMAIN CUSTNO
      TYPE INTEGER
      SET DEFAULT 2000;
  2. Renaming a domain.

    ALTER DOMAIN D_BOOLEAN TO D_BOOL;
  3. Deleting the default value and adding a constraint for the domain:

    ALTER DOMAIN D_DATE
      DROP DEFAULT
      ADD CONSTRAINT CHECK (VALUE >= date '01.01.2000');
  4. Changing the CHECK constraint:

    ALTER DOMAIN D_DATE
      DROP CONSTRAINT;
    
    ALTER DOMAIN D_DATE
      ADD CONSTRAINT CHECK
        (VALUE BETWEEN date '01.01.1900' AND date '31.12.2100');
  5. Changing the data type to increase the permitted number of characters:

    ALTER DOMAIN FIRSTNAME
      TYPE VARCHAR(50) CHARACTER SET UTF8;
  6. Adding a NOT NULL constraint:

    ALTER DOMAIN FIRSTNAME
      SET NOT NULL;
  7. Removing a NOT NULL constraint:

    ALTER DOMAIN FIRSTNAME
      DROP NOT NULL;

DROP DOMAIN

Drops an existing domain

Available in

DSQL, ESQL

Syntax
DROP DOMAIN domain_name

The DROP DOMAIN statement deletes a domain that exists in the database.It is not possible to delete a domain if it is referenced by any database table columns or used in any PSQL module.To delete a domain that is in use, all columns in all tables that refer to the domain have to be dropped and all references to the domain have to be removed from PSQL modules.

Who Can Drop a Domain

The DROP DOMAIN statement can be executed by:

  • Administrators

  • The owner of the domain

  • Users with the DROP ANY DOMAIN privilege

Example of DROP DOMAIN

Deleting the COUNTRYNAME domain
DROP DOMAIN COUNTRYNAME;