MySQL Questions and Answers – MySQL Setup – 1

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

1. Which of the following clauses is used to display information that match a given pattern?
c) IS
View Answer

Answer: a
Explanation: The ‘LIKE’ clause filters information that match a given pattern. ‘WHERE’ clause selects information that is specified by a condition. ‘IS’ is used to match the exact condition specified.

2. What column names are displayed when this SQL command is executed?

SHOW COLUMNS FROM tbl_name LIKE '%name';

a) suffixed with ‘name’
b) prefixed with ‘name’
c) suffixed with ‘%name’
d) prefixed with ‘%name’
View Answer

Answer: a
Explanation: The wildcard ‘%’ is used to indicate that any number of characters can replace it. All column names that end in ‘name’ are displayed. Additional information of columns like type and size are listed.

3. The special database that always exists after setting up MySQL in a computer is __________
a) sampdb
b) mysql
c) information_schema
d) readme_db
View Answer

Answer: c
Explanation: After installation of MySQL, ‘information_schema’ is the special database that always exists. ‘mysql’ can be seen depending on access rights. It holds the grant tables. ‘sampdb’ and ‘readme_db’ do not exist by default.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

4. In the following SQL code, InnoDB is __________

CREATE TABLE student (
		name CHAR(30),
		student_id INT,
		PRIMARY KEY (student_id)
	) ENGINE = InnoDB;

a) database name
b) table name
c) reference engine
d) storage engine
View Answer

Answer: d
Explanation: ‘InnoDB’ is the name of the ‘storage engine’ for the above table. The ‘ENGINE’ clause is used to specify the name of the storage engine that MySQL should use to handle the table being created. MySQL has several storage engines with its own properties.

5. Identify the table name in the following SQL statement.

	INSERT INTO student VALUES('Kyle','M',NULL);

a) Student
b) Values
c) Kyle
d) M
View Answer

Answer: a
Explanation: The ‘INSERT INTO’ clause here inserts a row in the table named ‘student’. The table has three fields. The first field or attribute value in the row/tuple is ‘Kyle’. The second attribute value is ‘M’ and the last attribute is set to NULL.

6. What is ‘xyz’ in the following SQL statement?

	SELECT abc FROM xyz;

a) row name
b) column name
c) table name
d) database name
View Answer

Answer: c
Explanation: The SELECT clause is used to retrieve information from some specified tables. It follows a specified format for information retrieval. Here, ‘abc’ can be a column name. It must be present in the table ‘xyz’.

7. Which operator is used to perform integer divisions in MySQL?
a) /
b) \
c) DIV
d) //
View Answer

Answer: c
Explanation: The operator ‘DIV’ is used to perform integer divisions in MySQL. ‘//’ is used in languages like Python to do the same. The operator ‘/’ performs floating point divisions and ‘\’ is facilitates escape sequences.

8. The NULL value also means ___________
a) value equal to zero
b) unknown value
c) negative values
d) a large value
View Answer

Answer: b
Explanation: The NULL value in MySQL is a special value. It represents ‘no value’ or an ‘unknown value’. A NULL value can’t be compared like normal known values since it gives undesirable results.

9. What does comparing a known value with NULL result into?
a) zero
b) a positive value
c) a negative value
d) null
View Answer

Answer: d
Explanation: In MySQL, NULL is not comparable to other known values. It will result in a NULL when compared to any value. The following statement would result in four NULLs: ‘SELECT NULL = 0, NULL < 0, NULL <> 0, NULL > 0’.

10. Which clause is used to sort query elements?
View Answer

Answer: d
Explanation: An ‘ORDER BY’ clause specifies the sort order. The data is sorted in ascending order by default. To sort in descending order, the keyword DESC is appended to the ‘ORDER BY’ clause. ‘GROUP BY’ is used to group the query results according to the criteria.

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.

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.