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;
Happiness Always
BKR Sivaprakash
BKR Sivaprakash