MySQL Questions and Answers – Status Variables

This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Status Variables”.

1. The statement that views status variables by aggregating the values over all connections is _____________
a) SHOW SESSION STATUS
b) SHOW LOCAL STATUS
c) SHOW GLOBAL STATUS
d) SHOW STATUS
View Answer

Answer: c
Explanation: The MySQL server maintains various status variables that provide information about its operations. These variables and their values can be viewed by using the SHOW [GLOBAL | SESSION] STATUS statement.

2. Which keyword inserted in the SHOW STATUS statement shows the values for the current connection?
a) GLOBAL
b) SESSION
c) LOCAL
d) DEFAULT
View Answer

Answer: b
Explanation: The optional ‘GLOBAL’ keyword in the statement SHOW [GLOBAL | SESSION] STATUS statement aggregates the values over all connections and ‘SESSION’ shows the values for the current connection.

3. What is the synonym for last_insert_id session variable?
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. The Audit_log_events system variable is of type _____________
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’.

5. mysql_next_result() does not return a status.
a) True
b) False
View Answer

Answer: b
Explanation: The function ‘mysql_next_result()’ returns a status and initiates retrieval of the next set if more results are available. The status is zero if more results are available and -1 if not.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. The option that executes all SQL statements in a SQL script irrespective of the number of errors is ____________
a) –ensure
b) –force
c) –violent
d) –run
View Answer

Answer: b
Explanation: If SQL queries in a file are run using mysql in batch mode, mysql either quits after the first error. If the –force option is specified all the queries are executed indiscriminately.

7. What is the number of attributes in the following SQL table?

advertisement
CREATE TABLE employee (
		emp_name CHAR(30),
		emp_id INT
	);

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

Answer: b
Explanation: The name of the table created is ’employee’. It has two attributes, namely, ’emp_name’ and ’emp_id’. The attributes are the columns in a table. emp_name is of type string and emp_id is of type integer.
advertisement

8. How many of the following do not return rows?

SELECT, SHOW, DESCRIBE

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

Answer: a
Explanation: In MySQL, it is important to note that ‘SELECT’ is not the only statement that returns some rows. Statements like ‘SHOW’, ‘DESCRIBE’, ‘EXPLAIN’ and ‘CHECK TABLE’ do so as well.

9. What does mysql_fetch_row() return?
a) integer
b) float
c) structure
d) pointer
View Answer

Answer: d
Explanation: ‘mysql_fetch_row()’ returns a MYSQL_ROW value, a pointer to an array of values. If the return value is assigned to a variable named row each value within the row is accessed as row[i].

10. The columns containing a binary value that include null bytes will print properly using the %s printf() format specifier.
a) True
b) False
View Answer

Answer: b
Explanation: The columns containing binary value including null bytes do not print properly using the %s printf() format specifier. printf() expects a null terminated string. It prints the column value only up to the first null byte.

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.