MySQL Database Multiple Choice Questions 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
Answer: c
Clarification: 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
Answer: b
Clarification: 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
Answer: b
Clarification: 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. The Audit_log_events system variable is of type _____________
a) string
b) integer
c) float
d) double
Answer: b
Clarification: 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
Answer: b
Clarification: 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.
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
Answer: b
Clarification: 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?
CREATE TABLE employee ( emp_name CHAR(30), emp_id INT );
a) 1
b) 2
c) 3
d) 30
Answer: b
Clarification: 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.
8. How many of the following do not return rows?
SELECT, SHOW, DESCRIBE
a) 0
b) 1
c) 2
d) 3
Answer: a
Clarification: 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
Answer: d
Clarification: ‘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
Answer: b
Clarification: 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.
