BUG #17247: How to avoid crating multiple Foreign keys on same column on same table.

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: nbipin29(at)gmail(dot)com
Subject: BUG #17247: How to avoid crating multiple Foreign keys on same column on same table.
Date: 2021-10-25 23:29:23
Message-ID: 17247-dcd5bfeb3d7ecef5@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17247
Logged by: bipsy Nair
Email address: nbipin29(at)gmail(dot)com
PostgreSQL version: 13.4
Operating system: Any OS
Description:

Issue: Postgres engine allows multiple FK on same columns for a same
table.This cause duplication and unwanted use of space . If we accidentally
run a script multiple times it creates the FK mulitple times.
Ran the following statement 3 times : to add a foreign key
ALTER TABLE admin.emp
ADD FOREIGN KEY (deptno)
REFERENCES admin.dept (deptno)
ON DELETE NO ACTION;

I see 3 its created thrice . In Oracle this statement should fail. Is there
any way this restriction can be applied on PG.
admin emp_deptno_fkey emp deptno admin dept deptno
admin emp_deptno_fkey1 emp deptno admin dept deptno
admin emp_deptno_fkey2 emp deptno admin dept deptno

Please advice.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Noah Misch 2021-10-26 01:51:57 Re: conchuela timeouts since 2021-10-09 system upgrade
Previous Message Tom Lane 2021-10-25 23:28:51 Re: BUG #17229: Segmentation Fault after upgrading to version 13