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

From terry@greatgulfhomes.com
Subject Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.
Date
Msg-id 002901c22784$17e5d5e0$2766f30a@development.greatgulfhomes.com
Whole thread Raw
In response to Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.  ("Gregory Wood" <gregw@com-stock.com>)
List 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@greatgulfhomes.com

> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Gregory Wood
> Sent: Tuesday, July 09, 2002 3:50 PM
> To: terry@greatgulfhomes.com
> Cc: PostgreSQL-General
> Subject: Re: [GENERAL] Bug in 7.2.1? -- ERROR: Adding columns with
> defaults is not implemented.
>
>
>
> ----- Original Message -----
> From: <terry@greatgulfhomes.com>
> To: "'ad wolf'" <adwolf1@yahoo.com>; <pgsql-general@postgresql.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@postgresql.org
>


pgsql-general by date:

Previous
From: Philip Hallstrom
Date:
Subject: Re: I am being interviewed by OReilly
Next
From: Christopher Murtagh
Date:
Subject: Re: I am being interviewed by OReilly