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

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: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On 8 May 2001, Nabil Sayegh wrote:

> On 08 May 2001 10:31:17 -0400, Vince Vielhaber wrote:
> > >
> > > 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.)


Vince Vielhaber -- KA8CSH    email: vev(at)michvhf(dot)com
         56K Nationwide Dialup from $16.00/mo at Pop4 Networking
        Online Campground Directory
       Online Giftshop Superstore

In response to

pgsql-bugs by date

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

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