|
|
 | | From: | Michael Fuhr | | Subject: | Adding a Column: default values now allowed | | Date: | Sun, 9 Jan 2005 00:41:56 -0700 |
|
|
 | PostgreSQL 8.0.0rc4
5.6.1 "Adding a Column" says:
Also, you cannot define a default value on a new column. According to the SQL standard, this would have to fill the new columns in the existing rows with the default value, which is not implemented yet.
Adding a column with a default appears to be implemented now:
CREATE TABLE foo (label text); INSERT INTO foo VALUES ('item 1'); INSERT INTO foo VALUES ('item 2'); INSERT INTO foo VALUES ('item 3'); ALTER TABLE foo ADD COLUMN value integer DEFAULT 123; SELECT * FROM foo; label | value --------+------- item 1 | 123 item 2 | 123 item 3 | 123 (3 rows)
-- Michael Fuhr http://www.fuhr.org/~mfuhr/
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly
|
|
 | | From: | Tom Lane | | Subject: | Re: Adding a Column: default values now allowed | | Date: | Sun, 09 Jan 2005 11:57:42 -0500 |
|
|
 | Michael Fuhr writes: > PostgreSQL 8.0.0rc4 > 5.6.1 "Adding a Column" says:
> Also, you cannot define a default value on a new column. According > to the SQL standard, this would have to fill the new columns in the > existing rows with the default value, which is not implemented yet.
Drat, I thought I'd caught all those. Thanks.
regards, tom lane
---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend
|
|
|