If I try to add a column that is not null with a default the SQL that gets generated is:

ALTER TABLE control
   ADD COLUMN security_options int;
ALTER TABLE control
   ALTER COLUMN security_options SET NOT NULL;
ALTER TABLE control
   ALTER COLUMN security_options SET DEFAULT 32;

This generates an error if the table already contains rows.

Whereas from 8.0 the following will work and ought to be used instead:

ALTER TABLE control
   ADD COLUMN security_options int not null default 32;


Thanks, Gary.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to