Subject | Re: [firebird-support] default field value retrospective behaviour |
---|---|
Author | Ivan Prenosil |
Post date | 2005-08-19T10:21:10Z |
"Dmitry Yemanov" wrote:
"Furthermore, you can add a column with a NOT NULL constraint on it
and immediately make your database unrestorable if you don't go in and
populate your existing rows.")
it is valid. I.e. with empty talbe
Alter Table tab Add NewCol Integer NOT NULL
should be o.k., but the same with non-empty table should fail
(although many peolpe will complain that it will break their ddl update scripts)
and correct procedure will be
Alter Table tab Add NewCol Integer;
Update tab Set NewCol=...;
Alter Table tab Alter NewCol Add constraint NOT NULL; << can't be done in current versions
Ivan
> "Ivan Prenosil" <Ivan.Prenosil@...> wrote:I was just describing how it currently works (and correcting Helen who said
> >
> > If you add *both* DEFAULT clause and NOT NULL constraint
> > you will get what you need.
>
> First, I wouldn't say this is exactly what he needs, because in fact records
> will still contain NULLs in this column. Perhaps nobody would notice the
> difference though.
"Furthermore, you can add a column with a NOT NULL constraint on it
and immediately make your database unrestorable if you don't go in and
populate your existing rows.")
>I agree. When adding new constraint, engine should always check whether
> Second, this hack may disappear in future versions (at least I always voted
> for that).
it is valid. I.e. with empty talbe
Alter Table tab Add NewCol Integer NOT NULL
should be o.k., but the same with non-empty table should fail
(although many peolpe will complain that it will break their ddl update scripts)
and correct procedure will be
Alter Table tab Add NewCol Integer;
Update tab Set NewCol=...;
Alter Table tab Alter NewCol Add constraint NOT NULL; << can't be done in current versions
Ivan