Saturday, 9 November 2019

Triggers in MySQL

Q: Which of the following is true of triggers in MySQL? Select all that apply.
Note: The way triggers works has changed slightly in recent versions. This question refers to the most recent version (after 6 or later).

Solution:


1.
A trigger can call a stored procedure.
2.
A trigger attached to table A that performs an operation on a table B, can cause the activation (triggering) of one or more triggers that are attached to table B.
3.
Specifying a trigger as FOR EACH ROW means the trigger is activated once for each row that is inserted, updated, or deleted.
4.
It is not possible to have multiple triggers with the same trigger event and action time (before/after).
5.
A trigger that attempts to alter the table that it is attached to will result in an error.


Solution:
Solution for 1: False, you can only execute stored procedures and Triggers in a stored procedure cannot be called directly.
Solution for 2: False, it does not create activation of several triggers at table B.
Solution for 3: True, trigger is activated when DML operations are triggered once for each row that is updated
Solution for 4: False, you can only create one trigger for an event per table as well as trigger event and action time
Solution for 5: False, unless the trigger and table posses the same name
 

No comments:

Post a Comment