From: sivapostgres@yahoo.com <sivapostgres@yahoo.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Creation of FK without enforcing constraint for existing data
Date: Tue, 2 Aug 2022 07:14:49 +0000 (UTC)
Message-ID: <929828491.130397.1659424489702@mail.yahoo.com> (raw)
References: <929828491.130397.1659424489702.ref@mail.yahoo.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: sivapostgres@yahoo.com
Subject: Re: Creation of FK without enforcing constraint for existing data
In-Reply-To: <929828491.130397.1659424489702@mail.yahoo.com>
References: <929828491.130397.1659424489702.ref@mail.yahoo.com> <929828491.130397.1659424489702@mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox