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

Поиск
Список
Период
Сортировка
От Rémi Cura
Тема Re: forcing a table (parent in inheritance) tor emain empty
Дата
Msg-id CAJvUf_uZUxu41oO-8rKKXhyD=iVjveLKj5JhRAcawaCyRxXUsA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: forcing a table (parent in inheritance) tor emain empty  (Manuel Gómez <targen@gmail.com>)
Ответы Re: forcing a table (parent in inheritance) tor emain empty  (Julien Rouhaud <julien.rouhaud@dalibo.com>)
Список pgsql-general
This solution is very nice.
Sadly the check is inherited by the children
(I only want the parent to be empty, not the children).

It seems the element that are not inherited are
  • Indexes
  • Unique constraints
  • Primary Keys
  • Foreign keys
  • Rules and Triggers

thanks anyway for the fast answer,
Cheers,
Rémi C

2016-10-11 18:33 GMT+02:00 Manuel Gómez <targen@gmail.com>:
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 по дате отправления:

Предыдущее
От: Sylvain MARECHAL
Дата:
Сообщение: Re: BDR: changing dsn on a running node
Следующее
От: Julien Rouhaud
Дата:
Сообщение: Re: forcing a table (parent in inheritance) tor emain empty