Subject Re: [ib-support] Fw: NOT NULL question
Author Helen Borrie
At 07:32 AM 18-12-01 +0100, Nico wrote:
>Hi list,
>
> Is there a way to add a NOT NULL constraint to a column, with ALTER TABLE ? (Interbase 6).

ALTER TABLE ADD CONSTRAINT MyColNotNull
CHECK (MyCol is not null);

I'd want to add a trigger to write a default value as well....and I'm not sure whether Prepare marks columns thus constrained as Required Fields in Delphi.

If the table doesn't have any dependencies, an alternative would be to create a duplicate table with NOT NULL on that column and pump the data across, drop the original table, then duplicate the new table the same way.

Don't forget to go through and find existing nulls first!

cheers,
Helen