Changing Column and Domain Definitions - Firebird

In both dialects, you can change the data type of a column in tables and domains. If you are migrating a database from another RDBMS, this can be useful. Certain restrictions apply when altering the data type:

  • Firebird does not allow the data type of a column or domain to be altered in a way that might result in data loss. For example, the number of characters in a column is not allowed to be smaller than the largest value in the column.
  • Converting a numeric data type to a character type requires a minimum length for the character type, as listed in Table.

Minimum Character Lengths for Numeric Conversions

Minimum Character Lengths for Numeric Conversions

Altering the Data Type of a Column

Use the ALTER COLUMN clause of the ALTER TABLE statement, for example:

ALTER TABLE table1 ALTER COLUMN field1 TYPE char(20);

Altering the Data Type of a Domain

Use the TYPE clauselet of the ALTER DOMAIN statement to change the data type of a domain, for example:

ALTER DOMAIN MyDomain TYPE VARCHAR(40);

Figure shows the data type conversions that are allowed.

Allowed data type conversions using ALTER COLUMN and ALTER DOMAIN

Allowed data type conversions using ALTER COLUMN and ALTER DOMAIN


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

Firebird Topics