Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

The locking statements LOCK TABLES and UNLOCK TABLES are not permitted in stored routines.(a) True(b) FalseThe question was posed to me in a national level competition.My question is based upon Security for Stored Programs and Views in section Stored Programs of MySQL

Answer»

Right answer is (a) True

The best explanation: In MySQL, the stored routines cannot contain ARBITRARY SQL STATEMENTS. For example, the locking statements LOCK TABLES and UNLOCK TABLES are not PERMITTED in the stored routines.

2.

Which privilege is enabled to create of alter a stored function?(a) SUPER(b) PRIOR(c) TOP(d) SUPERIORI got this question in a job interview.My question is based upon Security for Stored Programs and Views topic in division Stored Programs of MySQL

Answer»

The CORRECT answer is (a) SUPER

Explanation: In order to CREATE or alter a STORED function, the SUPER privilege should be given in addition to the CREATE ROUTINE privilege that is normally REQUIRED. Depending on the DEFINER value in the function definition SUPER might be required.

3.

What produces result sets?(a) View(b) SELECT(c) Stored function(d) TriggerThe question was posed to me by my school teacher while I was bunking the class.I'm obligated to ask this question of Security for Stored Programs and Views in portion Stored Programs of MySQL

Answer»

Correct option is (a) View

Easiest explanation: In MySQL, views are the STORED queries that when REFERENCED produce a result set. A view acts as a VIRTUAL table. A stored procedure is also a COMPONENT that can return result SETS.

4.

A stored procedure is invoked using the statement __________(a) INVOKE(b) SEE(c) CALL(d) RETURNI had been asked this question in semester exam.I'm obligated to ask this question of Security for Stored Programs and Views topic in section Stored Programs of MySQL

Answer» CORRECT ANSWER is (c) CALL

To explain: In MySQL, a stored procedure is invoked using the CALL statement. A stored procedure does not have a return VALUE but can MODIFY its PARAMETERS. It also returns some result sets.
5.

Triggers and events are invoked automatically by the server.(a) True(b) FalseThis question was posed to me in final exam.My question is taken from Security for Stored Programs and Views topic in chapter Stored Programs of MySQL

Answer» RIGHT answer is (a) True

Easy explanation: The triggers and events are invoked AUTOMATICALLY by the server, so the concept of invoking user is not applied. THUS, they have no SQL SECURITY characteristic and always execute with definer PRIVILEGES.
6.

When a user creates a stored program that accesses sensitive data but forgets that other people who can invoke the object have the same access, the security context is __________(a) good(b) bad(c) illegal(d) fareThe question was asked in an internship interview.Asked question is from Security for Stored Programs and Views in division Stored Programs of MySQL

Answer»

The correct answer is (b) bad

Best EXPLANATION: The security context is bad if a user creates a STORED program that accesses SENSITIVE data but forgets that other PEOPLE who can invoke the object have the same access to that data as its definer.

7.

When the security context enables carefully written stored programs to be set up that provide controlled access to tables for users, it is called __________(a) good(b) bad(c) illegal(d) fareI have been asked this question during an interview.Query is from Security for Stored Programs and Views in division Stored Programs of MySQL

Answer» CORRECT choice is (a) good

Explanation: The security context is good if it enables carefully WRITTEN stored PROGRAMS to be SET up that provide CONTROLLED access to tables for users who are not able to access them directly.
8.

The creation of a stored program is similar to the definition of a _______________(a) Trigger(b) Event(c) View(d) TableThe question was asked in an interview.I need to ask this question from Security for Stored Programs and Views in chapter Stored Programs of MySQL

Answer»

Correct choice is (c) VIEW

To explain: When a stored program is CREATED, an OBJECT is created that is to be executed LATER. This also the case when a view is defined: It sets up a SELECT statement intended for later invocation.

9.

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 columnI have been asked this question by my college director while I was bunking the class.Asked question is from Events in portion Stored Programs of MySQL

Answer»

The correct answer is (B) created the event

To EXPLAIN: 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.

10.

To create or drop events for a database, which privilege should be granted?(a) CREATE(b) DROP(c) PRIVILEGE(d) EVENTI had been asked this question in final exam.Query is from Events in division Stored Programs of MySQL

Answer»

Right choice is (d) EVENT

The BEST 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.

11.

Which clause specifies periodic execution at fixed intervals?(a) EVERY(b) ALL(c) AT(d) ALTERNATEI have been asked this question during an online interview.This question is from Events topic in section Stored Programs of MySQL

Answer»

Correct choice is (a) EVERY

The BEST I can EXPLAIN: 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.

12.

Which log does the event scheduler log to?(a) error(b) record(c) library(d) updateI have been asked this question by my college director while I was bunking the class.This intriguing question originated from Events topic in division Stored Programs of MySQL

Answer»

Right choice is (a) error

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.

13.

If the scheduler is stopped, no events run.(a) True(b) FalseI have been asked this question in final exam.My enquiry is from Events topic in division Stored Programs of MySQL

Answer»

The correct choice is (a) True

To explain: 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’.

14.

Which value of event_scheduler enables checking status but not changing it at runtime?(a) ON(b) OFF(c) DISABLED(d) ENABLEDThis question was posed to me in unit test.My question is taken from Events topic in division Stored Programs of MySQL

Answer»

Correct answer is (c) DISABLED

The 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.

15.

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’I had been asked this question in examination.Asked question is from Events in chapter Stored Programs of MySQL

Answer» RIGHT choice is (d) SHOW VARIABLES LIKE ‘event_scheduler’

Best 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.
16.

Which of the following lines is used to turn on the event scheduler?(a) event_scheduler = ON(b) eventscheduler = ON(c) event_scheduler_ON(d) events_scheduler_ONThis question was posed to me in a job interview.This intriguing question originated from Events in division Stored Programs of MySQL

Answer»

Correct option is (a) event_scheduler = 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.

17.

The event scheduler does not run by default.(a) True(b) FalseThis question was posed to me in exam.This intriguing question comes from Events topic in division Stored Programs of MySQL

Answer»

Right choice is (a) True

To elaborate: The EVENT scheduler does not run by default, so 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.

18.

Which of these is a stored program associated with a schedule?(a) Trigger(b) Event(c) Stored function(d) Stored procedureThis question was addressed to me in an online interview.My doubt stems from Events in division Stored Programs of MySQL

Answer»

Correct choice is (b) EVENT

Easy explanation: The MySQL version 5.1.6 and above has an event scheduler. It enables us to PERFORM time activated database operations. An event is a stored program that is ASSOCIATED with a SCHEDULE.

19.

The TRIGGER privilege is used for the table to be able to create and drop triggers for it.(a) True(b) FalseThis question was posed to me in unit test.The above asked question is from Triggers topic in division Stored Programs of MySQL

Answer»

The correct choice is (a) True

The explanation is: 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.

20.

Before MySQL 5.1.6 which privilege was required to create and drop triggers?(a) PRIVILEGE(b) TRIGGER(c) SUPER(d) MACROI had been asked this question during an interview.This key question is from Triggers in division Stored Programs of MySQL

Answer» RIGHT option is (c) SUPER

Best 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.
21.

Which statement is used to remove a trigger?(a) REMOVE(b) DELETE(c) DROP(d) CLEARThis question was posed to me by my college director while I was bunking the class.Query is from Triggers topic in division Stored Programs of MySQL

Answer»

Correct choice is (c) DROP

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.

22.

For which of the following are triggers not supported?(a) delete(b) update(c) insert(d) viewsI had been asked this question by my school teacher while I was bunking the class.My question is based upon Triggers in chapter Stored Programs of MySQL

Answer»

Right option is (d) VIEWS

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.

23.

Which statement is used to create a trigger?(a) CREATE TRIGGER(b) CREATE TRIGGERS(c) PRODUCE TRIGGER(d) PRODUCE TRIGGERSI had been asked this question by my college director while I was bunking the class.This question is from Triggers in section Stored Programs of MySQL

Answer»

The correct option is (a) CREATE TRIGGER

Easy 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.

24.

Triggers enable to enforce data integrity constraints.(a) True(b) FalseI got this question by my school principal while I was bunking the class.The above asked question is from Triggers topic in section Stored Programs of MySQL

Answer»

Right OPTION is (a) True

The 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.

25.

For the same input parameters, if the stored function returns the same result, it is called _____________(a) deterministic(b) non deterministic(c) regular(d) monotonousThe question was posed to me during an online interview.Asked question is from Stored Functions and Procedures topic in division Stored Programs of MySQL

Answer» RIGHT answer is (a) deterministic

Explanation: For the same input PARAMETERS, if the STORED function returns the same RESULT, it is CALLED a deterministic function. Otherwise, the stored function is called not deterministic.
26.

The IN, OUT and INOUT keywords do not apply to stored functions.(a) True(b) FalseThe question was asked during an online exam.My question is from Stored Functions and Procedures in portion Stored Programs of MySQL

Answer» RIGHT answer is (a) True

The explanation is: The IN, OUT and INOUT KEYWORDS do not apply to stored FUNCTIONS, TRIGGERS and events. Triggers and events do not have parameters at all. For the stored functions, all parameters are like IN parameters.
27.

Which procedure parameter enables the caller to pass in a value and get back a value?(a) IN(b) OUT(c) INOUT(d) GETINOUTThe question was posed to me during an interview for a job.The doubt is from Stored Functions and Procedures in chapter Stored Programs of MySQL

Answer»

Right choice is (C) INOUT

To EXPLAIN I would say: In an IN parameter, the CALLER passes a value into the procedure. An OUT parameter is exactly the opposite. The ‘INOUT’ parameter enables the caller to PASS in a value and also to get back a value.

28.

Which variable is set to zero when automatic privilege granting is not needed?(a) automatic_sp_privileges(b) automatic_ps_privileges(c) automatic_pg_privileges(d) automatic_gp_privilegesThe question was asked in an interview.Enquiry is from Stored Functions and Procedures in portion Stored Programs of MySQL

Answer»

The CORRECT ANSWER is (a) automatic_sp_privileges

Explanation: The automatic_sp_privileges system variable is set to zero when the automatic privilege GRANTING is not NEEDED and REVOCATION should not be allowed to occur. It is a crucial system variable.

29.

Which privilege must be given to the database to create a stored function or procedure?(a) CREATE ROUTINE(b) CREATE METHOD(c) CREATE FUNCTION(d) CREATE PROCEDUREThe question was posed to me in examination.This key question is from Stored Functions and Procedures topic in division Stored Programs of MySQL

Answer» CORRECT answer is (a) CREATE ROUTINE

To explain: The ‘CREATE ROUTINE’ privilege must be GIVEN for the database in ORDER to create a stored function or procedure. Stored FUNCTIONS and procedures always belong to a particular database.
30.

Suppose a stored function named PI() is written in the database ‘sampdb’. How would it be called?(a) PI()(b) sampdb.PI()(c) MySQL.PI()(d) db.PI()I have been asked this question during a job interview.This interesting question is from Stored Functions and Procedures topic in section Stored Programs of MySQL

Answer»

Right OPTION is (b) sampdb.PI()

The BEST I can explain: When a stored FUNCTION is DEFINED with the same name as a built in function, the function name should be qualified with the database name when it is invoked. The function ‘PI()’ is built in.

31.

How many values can be returned from a stored procedure?(a) 0(b) 1(c) 2(d) 3I have been asked this question in an online quiz.Asked question is from Stored Functions and Procedures topic in division Stored Programs of MySQL

Answer» RIGHT option is (a) 0

For explanation I would SAY: In MYSQL, unlike the stored functions, the stored procedures cannot return VALUES. They can be used to perform calculations or produce the result SETS passed back to the clients.
32.

How many values can be returned from a given stored function?(a) 0(b) 1(c) 2(d) 3This question was posed to me by my college professor while I was bunking the class.Asked question is from Stored Functions and Procedures topic in chapter Stored Programs of MySQL

Answer»

The CORRECT answer is (b) 1

The best explanation: In MySQL, the stored function cannot return multiple values. Instead, multiple stored FUNCTIONS can be written and INVOKED from within a single statement HOWEVER, they are different from stored PROCEDURES.

33.

To produce a stored function, which statement is used?(a) PRODUCE FUNCTION(b) CREATE FUNCTION(c) PRODUCE PROCEDURE(d) CREATE PROCEDUREThe question was asked in an interview for job.I want to ask this question from Stored Functions and Procedures in chapter Stored Programs of MySQL

Answer» RIGHT OPTION is (b) CREATE FUNCTION

The best explanation: The ‘CREATE FUNCTION’ statement is used to create a stored function in MySQL. The ‘CREATE PROCEDURE’ statement is used to create a stored procedure instead, from which values are not RETURNED.
34.

Which of the following statements does not modify the table?(a) INSERT(b) UPDATE(c) DELETE(d) SELECTThis question was posed to me in an interview.My question comes from Compound Statements and Statement Delimiters in division Stored Programs of MySQL

Answer» CORRECT option is (d) SELECT

Easy explanation: In MySQL, the ‘SELECT’ STATEMENT is USED to display the tables or their components according to some SPECIFIED conditions and clauses. It does not modify the table unlike the others.
35.

Stored routines refers to stored functions and procedures.(a) True(b) FalseI got this question in a job interview.The above asked question is from Compound Statements and Statement Delimiters in section Stored Programs of MySQL

Answer»

Right choice is (a) True

Explanation: In MySQL, the stored routines is a limited term. It REFERS only to the stored FUNCTIONS and PROCEDURES. Both TYPES of objects are DEFINED using the similar syntax and are discussed together.

36.

Which of the following characters cannot be used as a delimiter?(a) ,(b) .(c) ;(d) \This question was addressed to me in a national level competition.Asked question is from Compound Statements and Statement Delimiters topic in portion Stored Programs of MySQL

Answer» RIGHT option is (d) \

For explanation: In MySQL, the CHARACTER backslash character is reserved for specifying escape sequences. For EXAMPLE, the escape sequence ‘\t’ specifies a TAB space character. It cannot be used as a DELIMITER.
37.

Which command is used to redefined the mysql delimiter?(a) redefine_delim(b) delim_redefine(c) delimiter(d) redefineThis question was addressed to me in an online interview.My query is from Compound Statements and Statement Delimiters topic in portion Stored Programs of MySQL

Answer»

Right answer is (C) DELIMITER

To EXPLAIN: To redefine the mysql delimiter, the delimiter COMMAND is used. A delimiter is a sequence of characters. It specifies the boundary between the separate regions in DATA streams.

38.

Which character does the mysql client program recognize as a statement delimiter?(a) :(b) .(c) ;(d) ,I have been asked this question in an interview for job.The origin of the question is Compound Statements and Statement Delimiters topic in chapter Stored Programs of MySQL

Answer»

Right option is (c) ;

For explanation I WOULD SAY: By default, MYSQL itself recognizes the semicolon as a statement delimiter, so the delimiter must be redefined temporarily to CAUSE mysql to pass the ENTIRE stored program definition to the server.

39.

Stored programs improve database security.(a) True(b) FalseI had been asked this question in examination.The query is from Compound Statements and Statement Delimiters topic in division Stored Programs of MySQL

Answer»

Correct CHOICE is (a) True

Easy explanation: Stored programs improve database security because CONTROLLED access can be ENABLED to sensitive data by appropriate selection of the PRIVILEGES a program has when it executes.

40.

What executes on a time activated basis according to a schedule?(a) Stored program(b) Events(c) Triggers(d) Stored proceduresI got this question during an online interview.Question is from Compound Statements and Statement Delimiters topic in division Stored Programs of MySQL

Answer»

The correct option is (b) Events

The best I can explain: In MYSQL, the events EXECUTE on a time ACTIVATED basis according to a schedule. Triggers are DEFINED to execute when the table is modified via INSERT, DELETE or UPDATE statements.

41.

Which of these is defined to execute when the table is modified only?(a) Stored functions(b) Stored procedures(c) Triggers(d) EventsI had been asked this question in an online quiz.Asked question is from Compound Statements and Statement Delimiters topic in division Stored Programs of MySQL

Answer» CORRECT choice is (c) TRIGGERS

For explanation I would say: In MYSQL, triggers are ASSOCIATED with a table. They are defined to execute when the table is modified via INSERT, DELETE or UPDATE statements. MySQL supports objects to be stored on server side.
42.

Which of these return a result to the client?(a) Stored functions(b) Stored procedures(c) Triggers(d) EventsI had been asked this question in unit test.Enquiry is from Compound Statements and Statement Delimiters topic in chapter Stored Programs of MySQL

Answer»

Correct option is (a) Stored FUNCTIONS

Easy EXPLANATION: Stored functions return a result from a calculation and can be USED in expressions. Stored procedures do not return a result DIRECTLY but can be used to perform GENERAL computations.