Re: Creation of FK without enforcing constraint for existing data

From: "sivapostgres(at)yahoo(dot)com" <sivapostgres(at)yahoo(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Creation of FK without enforcing constraint for existing data
Date: 2022-08-02 07:14:49
Message-ID: 929828491.130397.1659424489702@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,
I need to create a Foreign Key for a table without enforcing the constraint for existing data.   Few orphan exists in existing data, which we plan to resolve it later.  
We use the following query to create the FK [ Which of course checks for the presence of record in referencing table]
ALTER TABLE public.table1    ADD CONSTRAINT "constraint1_FK" FOREIGN KEY (field1)    REFERENCES public.tabnle2(field2) MATCH SIMPLE    ON UPDATE RESTRICT    ON DELETE RESTRICT;
The facility NOT to check for the presence of the parent record is available in SQL Server.   Searching an equivalent option in PostGreSQL.  Is it available?   Else any other way to achieve this.
Happiness Always
BKR Sivaprakash

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavan Schneider 2022-08-02 07:43:14 Re: Creation of FK without enforcing constraint for existing data
Previous Message houzj.fnst@fujitsu.com 2022-08-02 03:20:55 RE: Support logical replication of DDLs