pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Adding NOT NULL columns in PostgreSQL 7.4?
2+ messages / 2 participants
[nested] [flat]

* Adding NOT NULL columns in PostgreSQL 7.4?
@ 2007-08-07 16:54 Michael Eshom <oldiesmann@oldiesmann.us>
  2007-08-07 17:49 ` Re: Adding NOT NULL columns in PostgreSQL 7.4? Michael Glaesemann <grzm@seespotcode.net>
  0 siblings, 1 reply; 2+ messages in thread

From: Michael Eshom @ 2007-08-07 16:54 UTC (permalink / raw)
  To: pgsql-sql

I'm currently using PostgreSQL 7.4.17, and trying to add a NOT NULL 
column results in an error about "Adding NOT NULL columns is not 
implemented". The only reports of this error I can find online relate to 
PostgreSQL 7.2, and further state that it was supposed to be implemented 
in PostgreSQL 7.3, so I can't figure out why it's still saying it's not 
implemented.
-- 

Michael Eshom
Christian Oldies Fan
Cincinnati, Ohio

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Adding NOT NULL columns in PostgreSQL 7.4?
  2007-08-07 16:54 Adding NOT NULL columns in PostgreSQL 7.4? Michael Eshom <oldiesmann@oldiesmann.us>
@ 2007-08-07 17:49 ` Michael Glaesemann <grzm@seespotcode.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Glaesemann @ 2007-08-07 17:49 UTC (permalink / raw)
  To: Michael Eshom <oldiesmann@oldiesmann.us>; +Cc: pgsql-sql


On Aug 7, 2007, at 11:54 , Michael Eshom wrote:

> I'm currently using PostgreSQL 7.4.17, and trying to add a NOT NULL  
> column results in an error about "Adding NOT NULL columns is not  
> implemented". The only reports of this error I can find online  
> relate to PostgreSQL 7.2, and further state that it was supposed to  
> be implemented in PostgreSQL 7.3, so I can't figure out why it's  
> still saying it's not implemented.

You can always check the release notes or the relevant documentation:

http://www.postgresql.org/docs/8.2/interactive/release-8-0.html#AEN82267

> E.29.4.4. Object Manipulation Changes

<snip />
>       Allow ALTER ... ADD COLUMN with defaults and NOT NULL  
> constraints; works per SQL spec (Rod)
>
>       It is now possible for ADD COLUMN to create a column that is  
> not initially filled with NULLs, but with a specified default value.

As a workaround in 7.4, this should work:

* Add the column (without the NOT NULL constraint)
* UPDATE the table with the values you want in the new column
* Add the NOT NULL constraint to the column.

You should be able to wrap this all in a transaction if so desired.

Hope this helps.

Michael Glaesemann
grzm seespotcode net





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-08-07 17:49 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-08-07 16:54 Adding NOT NULL columns in PostgreSQL 7.4? Michael Eshom <oldiesmann@oldiesmann.us>
2007-08-07 17:49 ` Michael Glaesemann <grzm@seespotcode.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox