Re: CHECK for 2 FKs to be non equal

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: CHECK for 2 FKs to be non equal
Date: 2017-03-11 10:52:27
Message-ID: AF44485A-FCF5-4AE2-8010-B99A902583CA@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> On 11 Mar 2017, at 10:41, Alexander Farber <alexander(dot)farber(at)gmail(dot)com> wrote:
>
> uid integer NOT NULL REFERENCES words_users(uid) CHECK (uid <> author) ON DELETE CASCADE,

> but get syntax error in 9.5:
>
> ERROR: syntax error at or near "ON"
> LINE 2: ...REFERENCES words_users(uid) CHECK (uid <> author) ON DELETE …

You put your CHECK constraint definition smack in the middle of the FK constraint definition, which starts with REFERENCES and ends with the delete CASCADE.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2017-03-11 13:09:23 Re: CHECK for 2 FKs to be non equal
Previous Message Francisco Olarte 2017-03-11 10:45:44 Re: CHECK for 2 FKs to be non equal