Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.

From: terry(at)greatgulfhomes(dot)com
To: "'Gregory Wood'" <gregw(at)com-stock(dot)com>
Cc: "'PostgreSQL-General'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.
Date: 2002-07-09 20:06:19
Message-ID: 002901c22784$17e5d5e0$2766f30a@development.greatgulfhomes.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey, if it's that easy to do, then why doesn't someone complete the command
ALTER TABLE ADD COLUMN to include the additional parameters for NOT NULL
and DEFAULT???

Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
terry(at)greatgulfhomes(dot)com

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Gregory Wood
> Sent: Tuesday, July 09, 2002 3:50 PM
> To: terry(at)greatgulfhomes(dot)com
> Cc: PostgreSQL-General
> Subject: Re: [GENERAL] Bug in 7.2.1? -- ERROR: Adding columns with
> defaults is not implemented.
>
>
>
> ----- Original Message -----
> From: <terry(at)greatgulfhomes(dot)com>
> To: "'ad wolf'" <adwolf1(at)yahoo(dot)com>; <pgsql-general(at)postgresql(dot)org>
> Sent: Monday, July 08, 2002 12:10 PM
> Subject: Re: [GENERAL] Bug in 7.2.1? -- ERROR: Adding columns
> with defaults
> is not implemented.
>
>
> > To implement the NOT NULL you either have to drop and
> recreate the table
> > (which is what I do) or manually insert the appropriate
> trigger (Ugh).
>
> Or update the system table:
>
> UPDATE pg_attribute SET attnotnull=True WHERE
> attrelid=(SELECT oid FROM
> pg_class WHERE relname='tablename') AND attname='fieldname'
>
> Where "tablename" is the name of the table to update and
> "fieldname" is the
> name of the NOT NULL field.
>
> > What I do is add the column without the NOT NULL or default,
> > then use the ALTER TABLE to set the column default,
> > then use pg_dump -t tablename databasename > table_backup
> > then vi table_backup and change the NULL to NOT NULL for the column
> > then drop the table
> > then reload the table with the NOT NULL constraint with:
> > psql -e database < table_backup
>
> Ugh, I find the system table UPDATE to be much easier to swallow :)
>
> Greg
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
> majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Murtagh 2002-07-09 20:14:36 Re: I am being interviewed by OReilly
Previous Message Philip Hallstrom 2002-07-09 20:01:46 Re: I am being interviewed by OReilly