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 14:31:17
Message-ID: Pine.BSF.4.30.0105081029020.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 05 May 2001 12:23:37 -0400, pgsql-bugs(at)postgresql(dot)org wrote:
> > Vince Vielhaber (vev(at)hub(dot)org) reports a bug with a severity of 3
> > The lower the number the more severe it is.
> >
> > Short Description
> > Alter table add column ignores default
> >
> > Long Description
> > Alter table add column ignores the default values in both v7.0x and 7.1. In the example code the table is created with one column having a default value of 'none'. An ALTER TABLE is done adding another varchar column also with a default value. \d table only shows the default from the create, not the alter. An insert also fails to add the default.
> >
> >
> >
> > Sample Code
> > foo=# create table foobar(name varchar(20),nickname varchar(10) default 'none');
> > CREATE
> > foo=# \d foobar
> > Table "foobar"
> > Attribute | Type | Modifier
> > -----------+-------------+----------------
> > name | varchar(20) |
> > nickname | varchar(10) | default 'none'
> >
> > foo=# alter table foobar add column address varchar(50) default 'none';
>
>
> 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?

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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Nabil Sayegh 2001-05-08 15:14:10 Re: Alter table add column ignores default
Previous Message Nabil Sayegh 2001-05-08 13:38:27 Re: Alter table add column ignores default