Subject | Re: alter column to NOT NULL |
---|---|
Author | Adam |
Post date | 2006-01-26T06:19:59Z |
--- In firebird-support@yahoogroups.com, "bcteh_98" <bcteh_98@y...> wrote:
rename the field, add a new not null field, copy the values from the
old field and then drop the old field. Yes that is a nightmare if you
have lots of dependencies or if you have lots of triggers that fire.
Important note:
Adding a not null field will make your database unrestorable until you
fill that field with values.
ALTER TABLE MYTABLE ADD MYFIELD INTEGER NOT NULL;
COMMIT;
UPDATE MYTABLE SET MYFIELD = MYOLDFIELD WHERE MYFIELD IS NULL;
COMMIT;
You should make sure you can backup and restore after making any DDL
change.
You did not hear the following from me, and you can do lots of damage
if you play around with the system tables.
RDB$RELATION_FIELDS.RDB$NULL_FLAG
Adam
>There is currently no command to do so. The safe way to do it is to
> Hi,
>
> What is the command to change the
> column to NOT NULL ?
>
> alter table TEST
> alter f3 type decimal(18,7) NOT null
>
> but still hit an error ..
> please help
rename the field, add a new not null field, copy the values from the
old field and then drop the old field. Yes that is a nightmare if you
have lots of dependencies or if you have lots of triggers that fire.
Important note:
Adding a not null field will make your database unrestorable until you
fill that field with values.
ALTER TABLE MYTABLE ADD MYFIELD INTEGER NOT NULL;
COMMIT;
UPDATE MYTABLE SET MYFIELD = MYOLDFIELD WHERE MYFIELD IS NULL;
COMMIT;
You should make sure you can backup and restore after making any DDL
change.
You did not hear the following from me, and you can do lots of damage
if you play around with the system tables.
RDB$RELATION_FIELDS.RDB$NULL_FLAG
Adam