Subject Re: [firebird-support] default field value retrospective behaviour
Author Ivan Prenosil
> I have a table, lets call it t. It already contains records.
> I am now adding a new timestamp field, I will call it starttime that I
> want it to default to a long time ago.
>
> ALTER TABLE T ADD STARTTIME TIMESTAMP DEFAULT '1/1/0001';
>
> The field is added, but the field is full of NULL values (the irony of
> something being full of NULL amuses me :) Is that behaviour correct,
> or should it fill the field with '1/1/0001's
>
> I know I can run a very simple query to do what I need, and I do not
> object to doing so (that is not what this post is about).
>
> UPDATE T SET STARTTIME = '1/1/0001';
>
> I was just curious to know how the standard says it should behave.

If you add *both* DEFAULT clause and NOT NULL constraint
you will get what you need.
(If will work correctly because your timestamp default is constant.
If you use e.g. 'NOW', the timestamp would change everytime you read the row,
until the row's new column is "materialized", either by update or backup/restore)

Ivan
http://www.volny.cz/iprenosil/interbase/