Home > Database > Mysql Tutorial > body text

Can Referential Integrity Checks in MySQL be Deferred Until Commit?

Susan Sarandon
Release: 2024-11-11 19:20:03
Original
348 people have browsed it

Can Referential Integrity Checks in MySQL be Deferred Until Commit?

Deferring Referential Integrity Checks in MySQL Until Commit

As discussed in a previous question, it can be desirable to delay referential integrity checks until the commit of a transaction. This can be useful when inserting a large number of related records into multiple tables.

However, according to the MySQL documentation, "InnoDB checks foreign key constraints immediately; the check is not deferred to transaction commit." This means that any foreign key constraint violations will cause an error during the insertion process, even within a transaction.

This limitation prevents certain operations that rely on deferred constraint checking, such as deleting a record that refers to itself using a foreign key. Therefore, it is not possible to defer referential integrity checks until commit in MySQL using InnoDB.

The above is the detailed content of Can Referential Integrity Checks in MySQL be Deferred Until Commit?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template