In Oracle, view the constraints between the primary key and the foreign key corresponding to a table. view the statement:

Source: Internet
Author: User

Record in table: user_constraints

 

  Select A. Owner, -- Primary Key owner
A. table_name, -- Primary Key table
B. column_name, -- Primary Key Column
C. Owner, -- Foreign key owner
C. table_name, -- Foreign key table
D. column_name -- Foreign key column
  From User_constraints
  Left   Join User_cons_columns B
On A. constraint_name = B. constraint_name
  Left   Join User_constraints C
On C. r_constraint_name = A. constraint_name
  Left   Join User_cons_columns d
On C. constraint_name = D. constraint_name
  Where A. constraint_type = ' P '
And A. table_name = ' Xxx '   -- Table for which you need to view the relationship between the primary and Foreign keys
  Order   By A. table_name

 

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.