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

How does MySQL handle errors during trigger execution?

WBOY
WBOYforward
2023-09-08 17:49:021771browse

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete