Subject Re: [firebird-support] Re: alter table question
Author Milan Babuskov
adsieben wrote:
> create table demo(
> id integer,
> value char default 'y'
> );
>
> You want to change "value" to default 'n':

Here's somewhat simpler version:

> First you have to add a new temporary field:
> alter table demo add temp_value char;

Instead of this, create a field with new default at once:

alter table demo add temp_value char default 'n';

> Copy all entries from field "value" to "temp_value":
> update demo
> set temp_value = value;
>
> Drop the original field:
> alter table demo drop value;

Good. Now, simply rename the temporary column and you're done:

alter table demo alter temp_value to value;

> I don't know by heart, if the existing fields are filled with the
> default value.

Only when you don't name them in a statement. In this all records are
overwritten by the UPDATE statement.

--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org