Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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.

pgadmin-support by date

Next:From: Raphaƫl EnriciDate: 2004-11-21 19:10:35
Subject: [mostly solved] pgAdmin III 1.2.0 RC2 Debian packages available
Previous:From: Nicholas WalkerDate: 2004-11-20 06:07:20
Subject: Escape Quotes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group