Query the table that the primary key is referenced by a foreign key

Source: Internet
Author: User

When you delete some of the tables, you will often encounter a primary key that is referenced by a foreign key in some relational tables and cannot be deleted, and this is the time to find out which table the primary key is referenced, and there is a view in Oracle that can help us do this, it is user_constraints, in the following example, ' TSP          _PK ' is the name of the primary key, ' R ' is a description of the foreign key relationship we want to query: SQL code Select C.constraint_name, C.table_name, C.constraint_type, C.r_constraint_name from user_constraints c where c.r_constraint_name = ' tsp_pk ' and c.constraint_type = ' R '

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.