MySQL Questions and Answers – Processing SQL Statements

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

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

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.
advertisement
advertisement

3. For failure, mysql_query() returns _______________
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.
Note: Join free Sanfoundry classes at Telegram or Youtube

4. How many of the following return rows?

SELECT, SHOW, DESCRIBE

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

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

5. mysql_fetch_row() returns _______________
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].

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

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

7. mysql_store_result() does not return a result set.
a) True
b) False
View Answer

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

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

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

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

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.