MySQL Questions and Answers – Triggers

This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Triggers”.

1. Triggers enable to enforce data integrity constraints.
a) True
b) False
View Answer

Answer: a
Explanation: In MySQL, a trigger can examine or change new data values to be inserted or used to update a row in a table. This enables the enforcement of the data integrity constraints.

2. Which statement is used to create a trigger?
a) CREATE TRIGGER
b) CREATE TRIGGERS
c) PRODUCE TRIGGER
d) PRODUCE TRIGGERS
View Answer

Answer: a
Explanation: In order to create a trigger, the CREATE TRIGGER statement is used. The definition indicates the particular type of statement for which the trigger activates and whether it activates before or after the rows are modified.

3. For which of the following are triggers not supported?
a) delete
b) update
c) insert
d) views
View Answer

Answer: d
Explanation: In MySQL, the triggers are run only after the table modifications like insert, update and delete are run. Triggers are not supported for views. In order to create a trigger, the CREATE TRIGGER statement is used.
advertisement
advertisement

4. Which statement is used to remove a trigger?
a) REMOVE
b) DELETE
c) DROP
d) CLEAR
View Answer

Answer: c
Explanation: In order to delete a trigger, the DROP TRIGGER statement is used. The DROP TRIGGER construct is used by writing the phrase ‘DROP TRIGGER’ followed by the scheme name specification.

5. Before MySQL 5.1.6 which privilege was required to create and drop triggers?
a) PRIVILEGE
b) TRIGGER
c) SUPER
d) MACRO
View Answer

Answer: c
Explanation: The privilege to create and drop triggers is version specific in MySQL. Before MySQL 5.1.6, the SUPER privilege was needed. Access control is more correctly handled post this version.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. The TRIGGER privilege is used for the table to be able to create and drop triggers for it.
a) True
b) False
View Answer

Answer: a
Explanation: In MySQL, because a trigger is associated with a table, the TRIGGER privilege is a must for that table to be able to create and drop triggers for it. The SUPER privilege was used pre 5.1.6.

7. What is abc in the following MySQL statement?

advertisement
CREATE TRIGGER abc (...) (...) ON def FOR EACH ROW ghi;

a) trigger name
b) table name
c) trigger statement
d) update statement
View Answer

Answer: a
Explanation: In MySQL, the trigger creation construct is the ‘CREATE TRIGGER’ construct. It specifies the trigger name, the type of statement for which it is activated, and the table name and statement.
advertisement

8. What is def in the following MySQL statement?

CREATE TRIGGER abc (...) (...) ON def FOR EACH ROW ghi;

a) trigger name
b) table name
c) trigger statement
d) update statement
View Answer

Answer: b
Explanation: The trigger creation construct in MySQL is the ‘CREATE TRIGGER’ construct. It specifies components like the trigger name, the type of statement for which it is activated, and the table name and statement.

9. What is ghi in the following MySQL statement?

CREATE TRIGGER abc (...) (...) ON def FOR EACH ROW ghi;

a) trigger name
b) table name
c) trigger statement
d) update statement
View Answer

Answer: c
Explanation: In MySQL, the trigger creation construct is the ‘CREATE TRIGGER’ construct. It specifies components like the trigger name, the type of statement for which it is activated, and the table name and statement.

10. What is def in the following MySQL statement?

DECLARE abc HANDLER FOR def ghi;

a) action
b) condition value
c) statement
d) null
View Answer

Answer: b
Explanation: The ‘DECLARE HANDLER’ statement is used to declare a handler. When a condition whose value matches def, MySQL will execute ghi and either continue or exit the current code block.

Sanfoundry Global Education & Learning Series – MySQL Database.

To practice all areas of MySQL Database, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.