What is MySQL trigger and triggering events related to it?

MySQLMySQLi Database

Basically, MySQL trigger is a set of statements stored in the database catalog. This database object is always associated with a table which is defined to be activated when a particular kind of event occurs for that table. In other sense, we can say that MySQL trigger is a special kind of stored procedure. Its main difference with the stored procedure is that it is not called directly like a stored procedure. It is called automatically when a data modification even against table occurs. The trigger can be executed when you run one of the following MySQL statements on the table: INSERT, UPDATE and DELETE and it can be invoked before or after the event. Triggers appear to execute quietly without the user even knowing of their existence. They cannot include COMMIT or ROLLBACK statements.

Triggering events are basically the action of time i.e. when trigger activates. Followings are the triggering events related to MySQL triggers:

  • INSERT − As its name suggests, this indicates the trigger event is related to insertion of data in MySQL table. In this case, the trigger would be triggered either before or after an insertion of data happens.
  • DELETE − As its name suggests, this indicates the trigger event is related to deletion of data in MySQL table. In this case, the trigger would be triggered either before or after an deletion of data happens.
  • UPDATE − As its name suggests, this indicates the trigger event is related to update of data in MySQL table. In this case, the trigger would be triggered either before or after an updating of data happens.
raja
Published on 22-Feb-2018 06:40:00
Advertisements