PostgreSQL View the primary foreign key relationship for the current table

Source: Internet
Author: User

PostgreSQL see which references to the current table are referenced as reference tables

--pg_constraint.contype:p (primary key), F (foreign key), U (unique), C (check)
--View the current table ID
SELECT OID, relname from pg_class WHERE relname = ' syslogfilter ';
--View the primary foreign KEY constraint information referencing the current table ID as a reference table
SELECT * from pg_constraint WHERE confrelid = ' 24935 ';
--View the names of those foreign keys
SELECT OID, relname from Pg_class WHERE oid in
(
SELECT conrelid from pg_constraint WHERE confrelid = ' 24935 '
);

PostgreSQL View the primary foreign key relationship for the current table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.