"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