MySQL Questions and Answers – Selecting, Creating, Dropping and Altering Databases

This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Selecting, Creating, Dropping and Altering Databases”.

1. Which statement is used to select a default database?
a) USE
b) CREATE
c) DROP
d) SCHEMA
View Answer

Answer: a
Explanation: MySQL has the facility to use various statements specifically at the database level. For selecting a default database, the keyword or clause used is the ‘USE’ statement.

2. Which keyword is the synonym for DATABASE?
a) TABLE
b) OBJECT
c) DB
d) SCHEMA
View Answer

Answer: d
Explanation: In any statement where the word ‘DATABASE’ occurs, the keyword ‘SCHEMA’ can be used as a synonym in place of it. In the literal sense, SCHEMA refers to the structure of the database.

3. It is not required to have an access privilege for a database before selecting it with ‘USE’.
a) True
b) False
View Answer

Answer: b
Explanation: In order to select a database as the default database for the MySQL server using the ‘USE’ statement, some access privilege for the database needs to be granted or attained.
advertisement
advertisement

4. Which keyword is used to create a database?
a) CREATE
b) SET
c) SETUP
d) LINK
View Answer

Answer: a
Explanation: The statement ‘CREATE DATABASE database_name;’ is used to create a database with the name ‘database_name’. A database qualifier should be used to specify the full name of the database.

5. The file created by the server to store the database attributes is __________
a) db.otp
b) dp.zip
c) db.opt
d) db.cls
View Answer

Answer: c
Explanation: Whenever a database is created in MySQL, the MySQL server creates a directory with the same name as the database. It creates the file db.opt to store the attributes.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. To create a database only if it doesn’t already exist, which clause is used?
a) IF EXISTS
b) IF NOT EXISTS
c) CREATE EXISTS
d) EXISTS IF
View Answer

Answer: b
Explanation: The ‘CREATE DATABASE’ statement supports many optional values. To create a database named ‘my_db’ only if it doesn’t already exist, we write ‘CREATE DATABASE IF NOT EXISTS my_db’.

7. If COLLATE is given without CHARACTER SET, the first part of the collation name gives the character set.
a) True
b) False
View Answer

Answer: a
Explanation: When a database is created, the ‘CHARACTER SET’ and ‘COLLATE’ values are specified. When ‘CHARACTER SET’ is given without ‘COLLATE’, the default collation is used.
advertisement

8. MySQL stores the database character set and collation attributes in the file _________
a) dp.opt
b) db.opt
c) db.sv
d) db.zip
View Answer

Answer: b
Explanation: The file named ‘db.opt’ is of a great significance to MySQL, espectially the MySQL server. It stores the database attributes along with the db charset and collation attributes.

9. Which statement is used to see the definition for an existing database?
a) SHOW CREATE DATABASE
b) SHOW DATABASE
c) SHOW CREATE
d) SHOW CREATE DATABASE TABLE
View Answer

Answer: a
Explanation: The statement ‘SHOW CREATE DATABASE’ is invoked to see the definition of an existing database in the MySQL server. It is followed by the qualified name of the database.
advertisement

10. Which statement makes changes to the database’s global attributes?
a) CHANGE
b) ALTER
c) ALTERNATE
d) UPDATE
View Answer

Answer: b
Explanation: The ‘ALTER TABLE’ statement is used to make changes to a database’s global attributes. This statement is followed by the name of the database, character set and collation.

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.