Re: Find out foreign key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Hi people,
> 
> I would like to know what's the system view that has information about 
> parent table and child table associated by Foreign Key!!
> 
> Is it possible to find out that information?
> 
> Thank you.

Here you go (tested on 8.1) :)

SELECT c.relname as table, r.conname as contraint,
pg_catalog.pg_get_constraintdef(r.oid, true) as constraint_definition
FROM pg_catalog.pg_constraint r, pg_catalog.pg_class c WHERE c.oid =
r.conrelid AND r.contype = 'f';

Bye,
Chris.


-- 

Chris Mair
http://www.1006.org




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux