From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Luke Pascoe" <luke(dot)p(at)kmg(dot)co(dot)nz> |
Cc: | "pgsql-general" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Inherited tables and NOT NULL (pg 7.2.1) |
Date: | 2003-01-24 05:41:05 |
Message-ID: | 10587.1043386865@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Luke Pascoe" <luke(dot)p(at)kmg(dot)co(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-01-24 05:43:39 | Re: Pg 7.3.1 & DBD::Pg 1.21 |
Previous Message | Tom Lane | 2003-01-24 05:25:58 | Re: psql 7.3.1 crash |