Subject | Re: [IBO] Add NOT NULL constraint within transaction |
---|---|
Author | Paul Vinkenoog |
Post date | 2007-01-29T23:47:18Z |
Hi David,
You don't need a temporary column; just issue these two DDL statements
and commit. Supposing the current column type is int:
create domain intnn as int not null;
alter table MyTable alter MyColumn type intnn;
Please make sure that there are no NULLs in the column *before* you
change the type! If you don't, any remaining NULLs will become
"invisible" in most clients, and you will probably only notice their
existence if you try to restore a backup that was made after the
change.
Hope this helps,
Paul Vinkenoog
> I want to add a NOT NULL constraint to an existing column. UnlessA late reply (maybe too late):
> I'm totally missing something, this can't be done in a single
> command and I'm on board with the idea of using a temporary column
> and accomplishing the task in several steps.
You don't need a temporary column; just issue these two DDL statements
and commit. Supposing the current column type is int:
create domain intnn as int not null;
alter table MyTable alter MyColumn type intnn;
Please make sure that there are no NULLs in the column *before* you
change the type! If you don't, any remaining NULLs will become
"invisible" in most clients, and you will probably only notice their
existence if you try to restore a backup that was made after the
change.
Hope this helps,
Paul Vinkenoog