Subject Re: [firebird-support] ALTER TABLE
Author Martijn Tonies

> is it possible to change a column definition from "null" to "not null"
> (provided that the column is not null for all rows)?
> I had a look at the IB 6 docs and the release notes for 1.5 but it
> seems that this is not possible. I was trying to add a primary key to
> a table which has been (accidently) created without a PK, but the ADD
> CONSTRAINT complains that the column is nullable (which is perfectly
> OK, because a PK with NULLs doesn't make sense at all).
> But I did not find a way to change it to NOT NULL without recreating
> the table and importing the data again...
> Am I right, or did I miss something?

There's no DDL statement to do this.

You can do it via a system table update. Database Workbench
does it the same way. It's RDB$NULL_FLAG in RDB$RELATION_FIELDS,
I believe :-)

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Upscene Productions