This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Processing SQL Statements”.
1. The general statement-issuing routine is _______________
a) mysql_real_query()
b) mysql_query_real()
c) mysql_image_query()
d) mysql_query_image()
View Answer
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.
2. Which of these is more restrictive?
mysql_query(), mysql_real_query()
a) mysql_query()
b) mysql_real_query()
c) same
d) machine dependent
View Answer
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.
3. For failure, mysql_query() returns _______________
a) 0
b) 1
c) -1
d) a non-zero
View Answer
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.
4. How many of the following return rows?
SELECT, SHOW, DESCRIBE
a) 0
b) 1
c) 2
d) 3
View Answer
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.
5. mysql_fetch_row() returns _______________
a) integer
b) float
c) structure
d) pointer
View Answer
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].
6. The columns containing binary value that include null bytes will not print properly using the %s printf() format specifier.
a) True
b) False
View Answer
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.
7. mysql_store_result() does not return a result set.
a) True
b) False
View Answer
Explanation: The functions ‘mysql_store_result()’ and ‘mysql_use_result()’ are similar because both of them take a connection handler argument and then return a result set after carrying out processes.
8. How many of the following take a connection handler as an argument?
mysql_store_result(), mysql_use_result()
a) 0
b) 1
c) 2
d) 3
View Answer
Explanation: The functions ‘mysql_store_result()’ and ‘mysql_use_result()’ are similar because both of them take a connection handler argument and then return a result set after carrying out the processes.
9. Which of these has a lower memory requirements?
mysql_use_result(), mysql_store_result()
a) mysql_use_result()
b) mysql_store_result()
c) same
d) machine dependent
View Answer
Explanation: The function ‘mysql_use_result()’ has lower memory requirements than ‘mysql_store_result()’ because only enough space to handle a single row at a time needs to be allocated. This can be faster.
10. How many of the following is considered as a special character by ‘mysql_real_escape_string()’?
null byte, single quote, backslash
a) 0
b) 1
c) 2
d) 3
View Answer
Explanation: The characters that ‘mysql_real_escape_string()’ considers special are the null byte, single quote, double quote, ‘backslash’, ‘newline’, ‘carriage return’ and the ‘Control-Z’.
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.
- Check MySQL Books
- Practice Programming MCQs
- Check Information Technology Books
- Apply for Programming Internship