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
When using Docker containers, it is more convenie...
In the previous article, we introduced three comm...
Table of contents Use two-way binding data in v-m...
PHP7 has been out for quite some time, and it is ...
Table of contents 1. Basic knowledge: 2. DHCP ser...
Directly post code and examples #Write comments w...
Today I downloaded mysql-5.7.18-winx64.zip from t...
Table of contents 1. Implementation of counter 2....
Let's look at the code first: ALTER TABLE rep...
This article shares the specific code of JS to im...
Preface In the previous article Detailed Explanat...
There are two situations 1. Start time and end ti...
Table of contents Abstraction and reuse Serial Se...
Table of contents 1. mixin.scss 2. Single file us...
Collapsed headers are a great solution for displa...