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

Поиск
Список
Период
Сортировка
От Gregory Wood
Тема Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.
Дата
Msg-id 073e01c22782$82d9d1a0$7889ffcc@comstock.com
обсуждение исходный текст
Ответ на Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.  (terry@greatgulfhomes.com)
Ответы Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.  (terry@greatgulfhomes.com)
Список pgsql-general
----- 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


В списке pgsql-general по дате отправления:

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: I am being interviewed by OReilly
Следующее
От: Philip Hallstrom
Дата:
Сообщение: Re: I am being interviewed by OReilly