Re: forcing a table (parent in inheritance) tor emain empty - Mailing list pgsql-general

From Manuel Gómez
Subject Re: forcing a table (parent in inheritance) tor emain empty
Date
Msg-id CAJWnFaOWrqYeDEkhLPkBy2KE_i1_9UwkyDygWEQiJBzEv5W2mA@mail.gmail.com
Whole thread Raw
In response to forcing a table (parent in inheritance) tor emain empty  (Rémi Cura <remi.cura@gmail.com>)
Responses Re: forcing a table (parent in inheritance) tor emain empty  (Rémi Cura <remi.cura@gmail.com>)
List pgsql-general
On Tue, Oct 11, 2016 at 12:27 PM, Rémi Cura <remi.cura@gmail.com> wrote:
> Hey dear list,
> I can't find a nice solution to enforce a necessary behaviour in my case :
> I want a parent table to remain empty.
>
> Of course I could define a trigger and return NULL in any case, but I'd like
> a more elegant approach using check or constraints.

You could probably do it with a simple constraint:

postgres=# create table dum(check (false));
CREATE TABLE
postgres=# insert into dum default values;
ERROR:  new row for relation "dum" violates check constraint "dum_check"
DETAIL:  Failing row contains ().


pgsql-general by date:

Previous
From: Scottix
Date:
Subject: Postgresql using lxd faild to find address
Next
From: Sylvain MARECHAL
Date:
Subject: Re: BDR: changing dsn on a running node