MySQL Questions and Answers – Functions

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

1. The server is told to accept spaces after function names by _____________
a) –sql-mode=SKIP_SPACE
b) –sql-mode=IGNORE_SPACE
c) –sql-mode=SPACE_IGNORE
d) –sql-mode=SPACE_SKIP
View Answer

Answer: b
Explanation: The MySQL server is told to accept spaces after function names by starting it with the ‘–sql-mode=IGNORE_SPACE’ option. Individual client programs can request this behavior by using the ‘CLIENT_IGNORE_SPACE’ option for ‘mysql_real_connect()’.

2. Which function returns NULL if expr1 = expr2?
a) CASE
b) IF()
c) IFNULL()
d) NULLIF()
View Answer

Answer: d
Explanation: The ‘CASE’ is used for the case operator. The function ‘IF()’ is used for the if/else construct. The function ‘IFNULL()’ is the Null if/else construct. ‘NULLIF()’ returns NULL if expr1 = expr2.

3. The operator that compares sounds is _____________
a) MATCH SOUNDS
b) CHECK SOUNDS
c) SOUNDS LIKE
d) SOUNDS SIMILAR
View Answer

Answer: c
Explanation: The operator ‘SOUNDS LIKE’ is used to compare sound. The ‘RLIKE’ is a synonym for ‘REGEXP’, which is a pattern matching using regular expressions. There are a lot of other operators for use.
advertisement
advertisement

4. The string function that returns the index of the first occurrence of substring is _____________
a) INSERT()
b) INSTR()
c) INSTRING()
d) INFSTR()
View Answer

Answer: b
Explanation: The string function ‘INSTR()’ is used to return the index of the first occurrence of the substring. The function ‘INSERT()’ is used to insert a substring at the specified position up to the specified number of characters.

5. CGI.pm does not support an object oriented style of use.
a) True
b) False
View Answer

Answer: b
Explanation: ‘CGI.pm’ supports an object oriented style of use which allows to invoke its functions without importing the names. To do this, a use statement is included and a CGI object is created.

6. There cannot be more than one column per table with the AUTO_INCREMENT attribute.
a) True
b) False
View Answer

Answer: a
Explanation: In MySQL, there can only be one column per table with the AUTO_INCREMENT attribute. It should also have an integer data type. The AUTO_INCREMENT is also allowed for floating point types.

7. What does the AUTO_INCREMENT sequences begin at by default?
a) 0
b) 1
c) -1
d) 2
View Answer

Answer: b
Explanation: The AUTO_INCREMENT column attribute provides unique numbers for column identification. AUTO_INCREMENT sequences normally begin at 1 and increase monotonically like 1, 2, 3, and so on.
advertisement

8. The one that is not optional is _____________

SELECT select_list FROM table_list WHERE row_constraint GROUP BY grouping_columns;

a) select_list
b) table_list
c) row_constraint
d) grouping_columns
View Answer

Answer: a
Explanation: Given above was a basic syntax of the SELECT statement. Everything in the syntax is optional except the ‘select_list’ option. All the others are free to be omitted, and will work fine.
advertisement

9. The join in which all the rows from the right table appear in the output irrespective of the content of the other table is ______________
a) CARTESIAN JOIN
b) CROSS JOIN
c) INNER JOIN
d) RIGHT JOIN
View Answer

Answer: d
Explanation: In a ‘RIGHT JOIN’, the output is produced for every row of the right table, even if it does not exist in the other table. This is the reason why it is called a ‘RIGHT JOIN’. ‘RIGHT JOIN’ and ‘LEFT JOIN’ are a kind of OUTER JOIN.

10. The facility that allows nesting one select statement into another is ______________
a) nesting
b) binding
c) subquerying
d) encapsulating
View Answer

Answer: c
Explanation: The ‘subquerying’ support provided by MySQL is a capability that allows writing one ‘SELECT’ statement within parentheses and nesting within another. This allows logically selecting content from tables.

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.