Get the App
SLTechnology News&Howtos  ›  Database  › 

How to deal with 1451 errors in navicat

Shulou Source: shulou.com Published: 2022-06-01 00:30:59 10月21日 Update

This article mainly introduces the navicat 1451 error handling, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.

What if there is an error 1451 in navicat?

[Err] 1451-Cannot delete or update aparent row: a foreign key constraint fails (`test`.`orders`, CONSTRAINT`fk _ orders_ customers` FOREIGN KEY (`cust_ id`) REFERENCES `customers` (`cust_ id`))

When deduplicating data is performed in navicat, the above error is reported: there is a foreign key blocking this operation.

Solution:

There are 2 kinds of error processing for foreign key delete operation in the table:

(1) temporary setting of foreign keys is invalid

(2) delete the table data of the foreign keys involved in the table

1. Foreign key failure mode

Mysql > SET FOREIGN_KEY_CHECKS = 0; # temporarily set foreign key invalidation mysql > execute action mysql > SET FOREIGN_KEY_CHECKS = 1; # restore foreign key after operation

Attachment: execute sql statements directly through the query Editor of navicat

2. The way to delete the table (this operation is not generally used)

Through the navicat tool, view the table associated with the foreign key of the table, and then delete.

Thank you for reading this article carefully. I hope the article "how to deal with 1451 errors in navicat" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Ways errors articles processing data value interests at the same time tools how to do methods more friends knowledge editing editors industries statements information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn MariaDB Xiaomi Linux