At 09:36 9/05/01 -0400, Bruce Momjian wrote:
>>
>> Is anybody planning to fix the problem with ALTER TABLE ADD CONSTRAINT...
>> in which the constraints are not applied to child tables?
>
>I thought we had not figured out how to inherit those, or at least
>certain constraints like UNIQUE. We do have on TODO:
>
> * Allow inherited tables to inherit index, UNIQUE constraint, and
> primary key [inheritance]
>
aaa=# create table t1(f1 integer check(f1<>0),primary key (f1));
aaa=# create table t1c() inherits (t1);
aaa=# \d t1c Table "t1c"Attribute | Type | Modifier
-----------+---------+----------f1 | integer | not null
Constraint: (f1 <> 0)
So PK is not inherited, but CHECK (and implied NOT NULL) seem to be.
Whereas,
aaa=# create table t1(f1 integer);
aaa=# create table t1c() inherits (t1);
aaa=# alter table t1 add constraint aaa check(f1<>0);
aaa=# \d t1c Table "t1c"Attribute | Type | Modifier
-----------+---------+----------f1 | integer |
ie. The CHECK constraints inherit only at the time of table creation. I
think this is a bug in ALTER TABLE for CHECK constraints.
----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \| | --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/