Subject | Re: [firebird-support] default value |
---|---|
Author | Martijn Tonies |
Post date | 2006-12-20T14:06:57Z |
> > > if I do this (there is 1 row already in the table)This is like this is since IB 6.0... On a required, newly added column, the
> > >
> > > 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
>
> that's what I thought but :
>
> SQL> ALTER TABLE tblsystemstatus add test Integer DEFAULT 0 NOT NULL;
> SQL> commit;
> SQL> select * from tblsystemstatus;
>
> LOGLIST TEST
> ==================================== ============
> ABCD 0
>
> hence my confusion
default
will be displayed on a SELECT. I'm not sure if it also physically updates
the
data.
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com