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
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
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
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.
4. Which statement is used to remove a trigger?
a) REMOVE
b) DELETE
c) DROP
d) CLEAR
View Answer
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
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.
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
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?
CREATE TRIGGER abc (...) (...) ON def FOR EACH ROW ghi;
a) trigger name
b) table name
c) trigger statement
d) update statement
View Answer
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.
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
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
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
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.
- Check MySQL Books
- Check Information Technology Books
- Practice Programming MCQs
- Apply for Programming Internship