MySQL Questions and Answers – User-Defined Variables

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

Answer: a
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

Answer: c
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

Answer: b
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’.
advertisement
advertisement

4. Multiple statement execution is disabled by default.
a) True
b) False
View Answer

Answer: a
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

Answer: a
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.
Note: Join free Sanfoundry classes at Telegram or Youtube

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

Answer: c
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.
advertisement

7. The one that is more restrictive is __________

advertisement
	mysql_query(), mysql_real_query()

a) mysql_query()
b) mysql_real_query()
c) same
d) machine dependent
View Answer

Answer: a
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

Answer: d
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.