FirebirdSQL logo

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.