Subject Re: [ib-support] changing a column type to not null
Author Helen Borrie
At 01:43 PM 07-05-02 +0200, you wrote:
>reading the ALTER TABLE ALTER COLUMN command on the langref, I am brought
>into thinking I can change the type of an existing column fron nullable to
>not null.

The langref gives this extension (only) for ALTER TABLE...ALTER COLUMN:
<alt_col_clause> = TO new_col_name
| TYPE new_col_datatype
| POSITION new_col_position

>However, I cannot find no way to put this into practice.
>Any hint ?

Two options:
1. Cleanest solution: create a new table with the desired attributes on
its columns and pump the
data. Do a RECREATE TABLE (Firebird) or DROP and CREATE on the original,
adding the new constraint, and re-pump.
2. Add before insert and before update triggers to check and (if desired)
default the value (this won't be helpful if you are seeking to place a
unique or primary key constraint on the column).

-- H

All for Open and Open for All
Firebird Open SQL Database · ·