This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Events”.
1. Which of these is a stored program associated with a schedule?
c) Stored function
d) Stored procedure
Explanation: The MySQL version 5.1.6 and above has an event scheduler. It enables to perform time activated database operations. An event is a stored program that is associated with a schedule.
2. The event scheduler does not run by default.
Explanation: The event scheduler does not run by default, so you it must be turned on if events are to be used. An event is a stored program that is associated with a schedule to perform database operations.
3. Which of the following lines is used to turn on the event scheduler?
a) event_scheduler = ON
b) eventscheduler = ON
Explanation: The line ‘event_scheduler = ON’ is put in the option file that the server reads. The event scheduler does not run by default. It must be turned on if events are to used in the database.
4. Which statement is used to check the status of the event scheduler at runtime?
a) SHOW STATUS OF ‘event_scheduler’
b) SHOW VARIABLES OF ‘event_scheduler’
c) SHOW STATUS LIKE ‘event_scheduler’
d) SHOW VARIABLES LIKE ‘event_scheduler’
Explanation: In MySQL, in order to check the status of the event scheduler at runtime, the statement: SHOW VARIABLES LIKE ‘event_scheduler’; is used. The event_scheduler is a system variable.
5. Which value of event_scheduler enables checking status but not changing it at runtime?
Explanation: In MySQL, if the event_scheduler is set to ‘DISABLED’ at startup, its status cannot be changed but can be checked at runtime. The events can be created but they will not execute.
6. If the scheduler is stopped, no events run.
Explanation: In MySQL, if the event scheduler is stopped, no events are run. It is also possible to leave the scheduler running but disable the individual events. This can be done with ‘DISABLED’.
7. Which log does the event scheduler log to?
Explanation: In MySQL, the event scheduler writes to the error log of the server, which can be checked for information about what the scheduler is doing. It logs the events as it runs them.
8. Which clause specifies periodic execution at fixed intervals?
Explanation: The ‘EVERY n interval’ clause specifies the periodic execution at fixed intervals. The interval values are like those used for the DATE_ADD() function, such as HOUR, DAY or MONTH.
9. To create or drop events for a database, which privilege should be granted?
Explanation: In MySQL, all events belong to some database, so the EVENT privilege must be granted for that database in order to both create or drop the events for it. An event is a stored program.
10. The default definer of an event is the user who _______________
a) created the database
b) created the event
c) created the table
d) created the column
Explanation: Unless the event has been altered, the default definer of an event is the user who created the event. In this case, the definer is the one who called the last ‘ALTER EVENT’ statement.
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.