When deleting a table or a piece of data in MySQL, [Err] 1451 -Cannot delete or update a parent row: aforeignkeyconstraintfails(...) This is because a foreign key association is set in MySQL, which makes it impossible to update or delete data. This can be avoided by setting the FOREIGN_KEY_CHECKS variable. To disable foreign key constraints, we can use: SETFOREIGN_KEY_CHECKS=0; Then delete the data To enable foreign key constraints, we can use: SETFOREIGN_KEY_CHECKS=1; To view the current value of FOREIGN_KEY_CHECKS, use the following command: SELECT @@FOREIGN_KEY_CHECKS; Summarize The above is all the content of this article about how to delete table data with foreign key constraints in MySQL. I hope it will be helpful to everyone. Interested friends can refer to: How to delete table data in MySQL, Analysis of MySQL variable declaration and stored procedure, Several important MySQL variables, Detailed explanation of MySQL prepare principle, etc. If you have any questions, please leave a message at any time and the editor will reply to you in time. You may also be interested in:
|
<<: A Preliminary Study on Vue Unit Testing
>>: How to increase your web performance by 3 times by turning on a parameter in Nginx
String extraction without delimiters Question Req...
Create a new table CREATE TABLE `person` ( `id` i...
Need to export the fields and properties of the t...
Table of contents 1. Write Webshell into outfile ...
Use javascript to implement a fixed sidebar, for ...
cursor A cursor is a method used to view or proce...
Effect: <!doctype html> <html> <he...
1 Introduction Binary log records SQL statements ...
1: Installation command pip install docker-compos...
This article describes how to build a MySQL maste...
Through the study and application of Node, we kno...
How to use the code in NetEase Blog: First log in...
Some people say that doing advertising is like bei...
After the container is started Log in to admin fi...
Installing XML extension in PHP Linux 1. Enter th...