MySQL Database Multiple Choice Questions on “Compound Statement Syntax”.
1. The statement that constructs a branching flow-control construct is _____________
a) BEGIN…END
b) CASE
c) ITERATE
d) LEAVE
Answer: b
Clarification: The ‘CASE’ statement provides a branching flow-control construct. When the initial expression, ‘expr’, is present, CASE compares it to the expression following each ‘WHEN’.
2. Which statement terminates the execution of a function?
a) BEGIN…END
b) RETURN
c) ITERATE
d) LOOP
Answer: b
Clarification: The ‘RETURN’ statement is used only within stored functions, not stored procedures, triggers, or events. When this statement is executed it terminates execution of the function.
3. Association between one or more MyISAM tables and the named key cache is set by _____________
a) BEGIN
b) CACHE INDEX
c) ALTER DATABASE
d) ALTER EVENT
Answer: b
Clarification: ‘CACHE INDEX’ sets up an association between one or more MyISAM tables and the named key cache which must already exist. The INDEX privilege is needed for each table named in the statement.
4. Which statement exits a labeled flow-control construct?
a) DESCRIBE
b) LEAVE
c) LOOP
d) RETURN
Answer: b
Clarification: The ‘LEAVE’ statement is used to exit a labeled flow-control construct. This statement must appear within the construct that has the given label. The syntax of the statement is ‘LEAVE label’.
5. What is the exec_stmt_ssl written in?
a) C++
b) C
c) Python
d) Perl
Answer: b
Clarification: In MySQL, the ‘sampdb’ distribution contains a source file named ‘exec_stmt_ssl.c’ from which the client program ‘exec_stmt_ssl’ can be built. There is a procedure to build this file.
6. What does ‘mysql_query()’ return on failure?
a) 0
b) 1
c) -1
d) a non-zero value
Answer: d
Clarification: Both of the functions named ‘mysql_query()’ and ‘mysql_real_query()’ return zero for statements that succeed. They return non zero for failure. A statement is successfully executed if the server accepts it.
7. When linking to a static MySQL C client library, the client library and the client application can use different compiler options.
a) True
b) False
Answer: b
Clarification: Generally, when linking to a static MySQL C client library, the client library and the client application must use the same compiler option when it is required to link the C runtime.
8. What can be used in place of MYSQL_SERVER_VERSION?
a) LIBMYSQL_VERSION
b) LIBMYSQL_VERSION_ID
c) MYSQL_VERSION_ID
d) MYSQL_ID
Answer: a
Clarification: The macros ‘LIBMYSQL_VERSION’ and ‘LIBMYSQL_VERSION_ID’ have the same values as ‘MYSQL_SERVER_VERSION’ and ‘MYSQL_VERSION_ID’ and the two sets of macros can be used in place of each other.
9. What can be used interchangeably with MYSQL_VERSION_ID?
a) LIBMYSQL_VERSION
b) LIBMYSQL_VERSION_ID
c) MYSQL_VERSION_ID
d) MYSQL_ID
Answer: b
Clarification: The ‘LIBMYSQL_VERSION’ and ‘LIBMYSQL_VERSION_ID’ macros have the same values as ‘MYSQL_SERVER_VERSION’ and ‘MYSQL_VERSION_ID’ and the two sets of macros can be used interchangeably.