MySQL Questions and Answers – Session-Only System Variables

This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Session-Only System Variables”.

1. Which of these is a read only variable?
a) error_count
b) big_tables
c) autocommit
d) foreign_key_checks
View Answer

Answer: a
Explanation: The session only system variable ‘error_count’ is a read only variable that indicates the number of errors generated by the last statement that can generate errors. The others are writable.

2. Which variable when set to 1 would enable foreign key checking for InnoDB tables?
a) error_count
b) identity
c) foreign_key_checks
d) autocommit
View Answer

Answer: c
Explanation: Setting the variable ‘foreign_key_checks’ to 0 or 1 disables or enables the foreign key checking for InnoDB tables. The default is to perform checking. Disabling key checks can also be helpful.

3. The synonym for last_insert_id session variable is _____________
a) insert_id
b) identity
c) sql_auto_is_null
d) sql_big_selects
View Answer

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

4. When building from source, the embedded server library is enabled by what?
a) –with-embedded-server
b) –with-server-embedded
c) –with-embedded-library
d) –with-library-embedded
View Answer

Answer: a
Explanation: While building from the source, the embedded server library is enabled by using the option ‘–with-embedded-server’ while running ‘configure’. This applies equally to MySQL 5.0 and 5.1.

5. How many among the following use NULL to indicate failure?

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
mysql_init(), mysql_real_connect()

a) 0
b) 1
c) 2
d) 3
View Answer

Answer: c
Explanation: Both of the client library routines named ‘mysql_init()’ and ‘mysql_real_connect()’ return a pointer to the connection handler in order to indicate success and NULL to indicate failure.
advertisement

6. How many among the following does not return a value?

mysql_close(), mysql_init, mysql_real_connect

a) 0
b) 1
c) 2
d) 3
View Answer

Answer: b
Explanation: It is not necessary that every Application Programming Interface call would return a value. For example, the client routine named ‘mysql_close()’ returns void, that is, it does not return a value.
advertisement

7. What returns a string containing an error message?
a) mysql_error()
b) mysql_errno()
c) mysql_sqlstate()
d) mysql_close()
View Answer

Answer: a
Explanation: The API call named ‘mysql_error()’ returns a string containing an error message. ‘mysql_close()’ does not return any value at all. ‘mysql_errno()’ returns a MySQL-specific numeric code.

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.