This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “User-Defined Variables”.
1. User defined variables are session specific.
a) True
b) False
View Answer
Explanation: The user defined variables are session specific. A user variable defined by one client cannot be seen or used by other clients. A user with access to the Performance Schema user_variables_by_thread table can see all user variables for all sessions is an exception.
2. Hexadecimal values assigned to user variables are treated as _____________
a) strings
b) non binary strings
c) binary strings
d) integers
View Answer
Explanation: The hexadcimal or bit values assigned to user variables are treated as binary strings. In order to assign a hexadecimal or bit value as a number to a user variable, it is used in a numeric context.
3. What is the type of Audit_log_events system variable?
a) string
b) integer
c) float
d) double
View Answer
Explanation: The system variable ‘Audit_log_events’ is of type integer. The variable scope if GLOBAL, that is, it can be viewed by issuing the statement ‘SHOW GLOBAL STATUS’, instead of ‘SESSION’.
4. Multiple statement execution is disabled by default.
a) True
b) False
View Answer
Explanation: The ‘multiple-statement’ execution is not enabled by default, so the server must be told that it is intended to be used. There are two ways to tell the server to enable the execution.
5. The option that enables multiple-statement execution is ____________
a) CLIENT_MULTI_STATEMENTS
b) CLIENT_STATEMENTS_MULTI
c) MULTI_STATEMENTS_CLIENT
d) MULTI_CLIENTS_STATEMENTS
View Answer
Explanation: There are two ways to enable the multiple-statement execution. The first is to add the ‘CLIENT_MULTI_STATEMENTS’ option in the flags argument to ‘mysql_real_connect()’ at connect time.
6. What is preferred when stored procedures are not being used?
CLIENT_MULTI_STATEMENTS, mysql_set_server_option()
a) CLIENT_MULTI_STATEMENTS
b) mysql_set_server_option()
c) any of the two
d) neither of the two
View Answer
Explanation: If the program does not use stored procedures anyone is suitable. If the program uses stored procedures and invokes a ‘CALL’ statement that returns a result set, the first method is better.
7. The one that is more restrictive is __________
mysql_query(), mysql_real_query()
a) mysql_query()
b) mysql_real_query()
c) same
d) machine dependent
View Answer
Explanation: The statement-issuing function other than ‘mysql_real_query()’ is ‘mysql_query()’. It is more restrictive in what it allows in the statement string although it is often easier to use.
8. What does mysql_query() return on failure?
a) 0
b) 1
c) -1
d) a non-zero
View Answer
Explanation: 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.
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.
- Practice Programming MCQs
- Check MySQL Books
- Apply for Programming Internship
- Check Information Technology Books