Changing Domain Definitions - Firebird

The DDL statement ALTER DOMAIN can be used to change any aspect of an existing domain except its NOT NULL setting. Changes that you make to a domain definition affect all column definitions based on the domain that have not been overridden at the table level.

A domain can be altered by its creator, the SYSDBA user, or (on Linux/UNIX) any user with operating system root privileges.

Using ALTER DOMAIN you can

  • Rename the domain
  • Modify the data type
  • Drop an existing default value
  • Set a new default value
  • Drop an existing CHECK constraint
  • Add a new CHECK constraint

Here’s the syntax:

Examples

This statement sets a new default value for the BOOK_GROUP domain:

ALTER DOMAIN BOOK_GROUP SET DEFAULT -1;

In this statement, the name of the BOOK_GROUP domain is changed to PUBL_GROUP:

ALTER DOMAIN BOOK_GROUP TO PUBL_GROUP;

Constraints on Altering Data Types

The TYPE clause of ALTER DOMAIN allows the data type to be changed to another, permitted data type.

Any type conversion that could result in data loss is disallowed. For example, the number of characters in a domain could not be made smaller than the size of the largest value in any column that uses it.

Converting a numeric data type to a character type requires a minimum length for the character type.

The following statement changes the data type of a CHAR(80) domain, BOOK_TITLE, to VARCHAR(100):

ALTER DOMAIN BOOK_TITLE TYPE VARCHAR(100);

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Firebird Topics