Subject | Re: [firebird-support] default value |
---|---|
Author | Nick Upson |
Post date | 2006-12-20T13:54:09Z |
On 20/12/06, Markus Ostenried <macnoz@...> wrote:
SQL> ALTER TABLE tblsystemstatus add test Integer DEFAULT 0 NOT NULL;
SQL> commit;
SQL> select * from tblsystemstatus;
LOGLIST TEST
==================================== ============
ABCD 0
hence my confusion
> On 12/20/06, Nick Upson <nick.upson@...> wrote:that's what I thought but :
> > if I do this (there is 1 row already in the table)
> >
> > ALTER TABLE mytable add test Integer DEFAULT 0 NOT NULL;
> > commit;
>
> The default value you specified is only used if you are inserting a
> new record and if your insert statement does not contain the
> test-field.
> When altering a table like this the default isn't applied to already
> existing records. You should always execute an update statement after
> adding a not-null-field to fill the field for existing records
> yourself.
>
> bye,
> Markus
SQL> ALTER TABLE tblsystemstatus add test Integer DEFAULT 0 NOT NULL;
SQL> commit;
SQL> select * from tblsystemstatus;
LOGLIST TEST
==================================== ============
ABCD 0
hence my confusion