I'm trying to add a column to a firebird table. The column should have a default value 1 but initially for already existing rows the value should be set to 0. And that should happen in one transaction.
I tried
ALTER TABLE MYTABLE ADD MYCOLUMN SMALLINT DEFAULT 1 NOT NULL;
UPDATE MYTABLE SET MYCOLUMN = 0;
but that's not allowed in one transaction, because the update won't see the new column. I also tried:
ALTER TABLE MYTABLE ADD MYCOLUMN SMALLINT DEFAULT 0 NOT NULL;
ALTER TABLE MYTABLE ALTER COLUMN MYCOLUMN SET DEFAULT 1 NOT NULL;
Hoping that the column will be 0 afterwards but it will be 1.
More options to get what I want in one transaction?