Home > Database > Mysql Tutorial > How does MySQL handle errors during trigger execution?

How does MySQL handle errors during trigger execution?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-09-08 17:49:02
forward
1791 people have browsed it

How does MySQL handle errors during trigger execution?

Assuming that if an error occurs during trigger execution, MySQL can handle it as follows -

  • If the BEFORE trigger fails, the execution will not execute accordingly OK.
  • The BEFORE trigger is activated when an attempt is made to insert or modify a row, regardless of whether subsequent attempts are successful.
  • Only execute AFTER triggers if any BEFORE triggers and row operations execute successfully.
  • An error during a BEFORE or AFTER trigger causes the entire statement that caused the trigger to be called to fail.
  • For transactional tables, statement failure should cause all changes performed by that statement to be rolled back. A failed trigger causes the statement to fail, so a failed trigger also causes a rollback. For non-transactional tables, such rollback cannot be performed, so although the statement fails, any changes performed before the point of error are still valid.

The above is the detailed content of How does MySQL handle errors during trigger execution?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template