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

Adding a Column: default values now allowed

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: pgsql-docs(at)postgresql(dot)org
Subject: Adding a Column: default values now allowed
Date: 2005-01-09 07:41:56
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-docs
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;
 label  | value 
 item 1 |   123
 item 2 |   123
 item 3 |   123
(3 rows)

Michael Fuhr


pgsql-docs by date

Next:From: Tom LaneDate: 2005-01-09 16:57:42
Subject: Re: Adding a Column: default values now allowed
Previous:From: Tom LaneDate: 2005-01-06 20:54:01
Subject: Re: syntax error with example sql of createtable

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