This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “User-Defined Variables”.
1. User defined variables are session specific.
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 _____________
b) non binary strings
c) binary strings
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 numeric context.
3. The synonym for last_insert_id session variable is _____________
Explanation: The session only system variable ‘identity’ is a synonym for the ‘last_insert_id’ session variable. Setting ‘last_insert_id’ specifies the value to be returned by the function ‘LAST_INSERT_ID()’.
4. What is the type of Audit_log_events system variable?
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’.
5. Multiple statement execution is disabled by default.
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.
6. The option that enables multiple-statement execution is ____________
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.
7. What is preferred when stored procedures are not being used?
c) any of the two
d) neither of the two
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.
8. What is the general statement-issuing routine?
Explanation: The general statement-issuing routine is mysql_real_query(). The statement is provided as a counted string (a string plus a length). The length of the statement string must be kept track of.
9. The one that is more restrictive is __________
d) machine dependent
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.
10. What does mysql_query() return on failure?
d) a non-zero
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.