Re: Inherited tables and NOT NULL (pg 7.2.1)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Inherited tables and NOT NULL (pg 7.2.1)
Дата
Msg-id 10587.1043386865@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Inherited tables and NOT NULL (pg 7.2.1)  ("Luke Pascoe" <luke.p@kmg.co.nz>)
Список pgsql-general
"Luke Pascoe" <luke.p@kmg.co.nz> writes:
> Well I was trying out adding a new column to my "Parent" table, I wanted a
> not null, defaulted, integer column, so I did:

> temp=> ALTER TABLE Parent ADD ddd INT;
> ALTER
> temp=> UPDATE Parent SET ddd = 0;
> UPDATE 2
> temp=> ALTER TABLE Parent ALTER COLUMN ddd SET DEFAULT 0;
> ALTER
> temp=> ALTER TABLE Parent ADD CONSTRAINT ddd_nn CHECK (ddd IS NOT NULL);
> ERROR:  AlterTableAddConstraint: rejected due to CHECK constraint ddd_nn

[ scratches head ... ]  That looks like it should work.  The ALTER ADD
COLUMN should have recursively added the column to all the child tables
too, and the UPDATE should have recursively hit all the children.  So
there should be no rows left anywhere where the constraint could fail.

Could you provide a complete example?  There must be something odd about
the parent or child table schemas, which you have not showed us.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: psql 7.3.1 crash
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Pg 7.3.1 & DBD::Pg 1.21