Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Oracle find out which table the foreign key is built on?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

How to find out which table the foreign key is built on

Sometimes when deleting a table record, it will report an error that the foreign key constraint cannot be deleted.

If you do not understand the relationship between tables, you can query the table on which the foreign key is built by using the following statement:

Select * from dba_constraints where constraint_name='xxx' and constraint_type ='R'

For example, the following error is reported in my program log. I want to know which table the foreign key is on.

2015-09-08 18:28:18 [main:261597003]-[ERROR] java.sql.SQLException: ORA-02291: violation of complete constraint (IRP.FK66EC57AF5158B9FB)-parent keyword not found

Select * from dba_constraints where constraint_name='FK66EC57AF5158B9FB' and constraint_type ='R'

For example:

Execution of delete from tablename Times error:

ORA-02292: integrity constraint (CCSYS.FK_T_BME_TASKRUNRESULT_TASKID) violated-child record found

You can do this by executing

Select table_name from dba_constraints where constraint_name='FK_T_BME_TASKRUNRESULT_TASKID' and constraint_type ='R'

Query that the foreign key is built on the T_BME_TASKRUNRESULT table, delete the t_bme_task table first, and then delete the TASKRUNSULT table record.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report