Alter table not correct for Postgres 8.0+

From: Gary Doades <gpd(at)gpdnet(dot)co(dot)uk>
To: Pgadmin Support <pgadmin-support(at)postgresql(dot)org>
Subject: Alter table not correct for Postgres 8.0+
Date: 2004-11-20 18:43:33
Message-ID: 419F9055.2020105@gpdnet.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

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.

Browse pgadmin-support by date

  From Date Subject
Next Message Raphaël Enrici 2004-11-21 19:10:35 [mostly solved] pgAdmin III 1.2.0 RC2 Debian packages available
Previous Message Nicholas Walker 2004-11-20 06:07:20 Escape Quotes