Subject | Re: [firebird-support] Re: NOT NULL constraint not being enforced by Firebird |
---|---|
Author | Michael Weissenbacher |
Post date | 2006-06-10T09:02:23Z |
Hello,
and I've tried to test it yesterday. Benton metioned that he defined the
field with "DEFAULT 0 NOT NULL". I tried this on my system and Firebird
behaved like it should: it pre-set the value 0 into the column.
Here is what I did via DDL, works flawlessly:
ALTER TABLE TESTNULLS ADD TESTFIELD NUMERIC(9,2) DEFAULT 0 NOT NULL;
Benton, could it be that you added the "DEFAULT 0" later on, via some
tool like IBExpert?
Michael
> This is a known issue.I've known this issue (adding not null columns WITHOUT a default value)
>
> If you add a not null field to a table, you need to remember to set
> values to all pre-existing records in that field. The existing records
> are not checked when such a constraint is added. The values are
> policed basically in before insert or update triggers.
and I've tried to test it yesterday. Benton metioned that he defined the
field with "DEFAULT 0 NOT NULL". I tried this on my system and Firebird
behaved like it should: it pre-set the value 0 into the column.
Here is what I did via DDL, works flawlessly:
ALTER TABLE TESTNULLS ADD TESTFIELD NUMERIC(9,2) DEFAULT 0 NOT NULL;
Benton, could it be that you added the "DEFAULT 0" later on, via some
tool like IBExpert?
Michael