Lists: | pgsql-general |
---|
From: | Clodoaldo Neto <clodoaldo(dot)pinto(dot)neto(at)gmail(dot)com> |
---|---|
To: | PostgreSQL - General ML <pgsql-general(at)postgresql(dot)org> |
Subject: | Non inheritable check constraint |
Date: | 2012-03-05 13:19:43 |
Message-ID: | CA+Z73LHVYPBxO3ecYvg_Sc=K3yDz10jsxTySC+S1KkB5WvQAJA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
I have gone through the issue of making a parent table not writable. After
discussing it (1) I adopted the trigger solution. But I think that a
trigger is just an invisible layer over the database model and so I'm
naively proposing a new syntax to postgresql. It would inform that the
check constraint is not inheritable:
create table t (c integer check NOT INHERITABLE (false));
I found a model visible solution but it only prevents non null values from
being inserted. Or only prevents all inserts if that column is not null:
create table tfk (c integer unique check(false));
create table t (c integer, foreign key (c) references tfk(c));
Regards, Clodoaldo
(1)
http://stackoverflow.com/questions/9545783/how-to-prevent-inserts-in-a-table
From: | Clodoaldo Neto <clodoaldo(dot)pinto(dot)neto(at)gmail(dot)com> |
---|---|
To: | PostgreSQL - General ML <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Non inheritable check constraint |
Date: | 2012-05-14 12:43:42 |
Message-ID: | CA+Z73LEz2oh8_DSWVNi8UEaUvqTSoht3YNpstt9mNy3JaJRNQw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
2012/3/5 Clodoaldo Neto <clodoaldo(dot)pinto(dot)neto(at)gmail(dot)com>
> I have gone through the issue of making a parent table not writable. After
> discussing it (1) I adopted the trigger solution. But I think that a
> trigger is just an invisible layer over the database model and so I'm
> naively proposing a new syntax to postgresql. It would inform that the
> check constraint is not inheritable:
>
> create table t (c integer check NOT INHERITABLE (false));
>
>
It will be in 9.2:
-
Allow CHECK constraints to be declared NO INHERIT (Nikhil Sontakke, Alex
Hunsaker)
This makes them enforceable only on the parent table, not on child
tables.
I don't know if it was already there when I asked but ! Thank You !
Clodoaldo
I found a model visible solution but it only prevents non null values from
> being inserted. Or only prevents all inserts if that column is not null:
>
> create table tfk (c integer unique check(false));
> create table t (c integer, foreign key (c) references tfk(c));
>
> Regards, Clodoaldo
>
> (1)
> http://stackoverflow.com/questions/9545783/how-to-prevent-inserts-in-a-table
>