You need to create a trigger on the EMP table that monitors every row that is changed and places this information into the AUDIT_TABLE. What type of trigger do you create?

  1. FOR EACH ROW trigger on the EMP table.

  2. Statement-level trigger on the EMP table.

  3. FOR EACH ROW trigger on the AUDIT_TABLE table

  4. Statement-level trigger on the AUDIT_TABLE table


Correct Option: A
Explanation:

To solve this question, the user needs to know the concept of triggers in database management systems. The user must also understand the difference between statement-level triggers and row-level triggers.

In this scenario, we need to create a trigger that monitors every row that is changed in the EMP table and inserts that information into the AUDIT_TABLE. Therefore, we need to create a row-level trigger.

Now, let's go through each option and explain why it is right or wrong:

A. FOR EACH ROW trigger on the EMP table. This option is correct. A FOR EACH ROW trigger on the EMP table will monitor every row that is changed in the EMP table and execute the trigger code for each affected row. This is the type of trigger that we need to create to accomplish the task.

B. Statement-level trigger on the EMP table. This option is incorrect. A statement-level trigger on the EMP table triggers once for each SQL statement that is executed, regardless of the number of rows that are affected. This type of trigger would not be suitable for the task at hand.

C. FOR EACH ROW trigger on the AUDIT_TABLE table. This option is incorrect. A FOR EACH ROW trigger on the AUDIT_TABLE table would monitor every row that is changed in the AUDIT_TABLE table, but this is not what we need. We need to monitor changes in the EMP table.

D. Statement-level trigger on the AUDIT_TABLE table. This option is incorrect. A statement-level trigger on the AUDIT_TABLE table would only trigger once for each SQL statement that is executed, regardless of the number of rows that are affected. This type of trigger would not be suitable for the task at hand.

The Answer is: A. FOR EACH ROW trigger on the EMP table.

Find more quizzes: