Re: forcing a table (parent in inheritance) tor emain empty

From: Manuel Gómez <targen(at)gmail(dot)com>
To: Rémi Cura <remi(dot)cura(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: forcing a table (parent in inheritance) tor emain empty
Date: 2016-10-11 16:33:46
Message-ID: CAJWnFaOWrqYeDEkhLPkBy2KE_i1_9UwkyDygWEQiJBzEv5W2mA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 11, 2016 at 12:27 PM, Rémi Cura <remi(dot)cura(at)gmail(dot)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 ().

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sylvain MARECHAL 2016-10-11 16:55:13 Re: BDR: changing dsn on a running node
Previous Message Rémi Cura 2016-10-11 16:27:12 forcing a table (parent in inheritance) tor emain empty