Re: Alter table add column ignores default

From: Vince Vielhaber <vev(at)michvhf(dot)com>
To: Nabil Sayegh <nsmail(at)sayegh(dot)de>
Cc: <vev(at)hub(dot)org>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Alter table add column ignores default
Date: 2001-05-08 15:19:26
Message-ID: Pine.BSF.4.30.0105081115350.66156-100000@paprika.michvhf.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 8 May 2001, Nabil Sayegh wrote:

> On 08 May 2001 10:31:17 -0400, Vince Vielhaber wrote:
> > > http://hermes.swu.bg/postgres/postgres/sql-altertable.htm
> > > The correct syntax is:
> > > ALTER TABLE foobar add column address varchar(50);
> > > ALTER TABLE foobar alter column address set default 'none';
> >
> > If this:
> >
> > alter table foobar add column address varchar(50) default 'none';
> >
> > is the incorrect syntax, why does it not fail or at least give a
> > warning?
>
>
>
> Sorry, I meant: Try this workaround :)

Ok, now I'm officially confused :)

Is it a bug that there's no error or warning or is it a bug that it
ignores the default? Ok, I just found it:

---
In the current implementation, default and constraint clauses for the new
column will be ignored. You can use the SET DEFAULT form of
ALTER TABLE to set the default later. (You will also have to update the
already existing rows to the new default value, using UPDATE.)
---

Thanks!

Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev(at)michvhf(dot)com http://www.pop4.net
56K Nationwide Dialup from $16.00/mo at Pop4 Networking
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2001-05-08 16:07:27 Re: Paths for C functions (was Re: Re: backend dies on 7.1.1 loading large datamodel.)
Previous Message Todd R. Eigenschink 2001-05-08 15:15:19 REQ: build src/backend/postgres w/o -lncurses or -lreadline