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
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
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
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.
4. Which keyword is used to create a database?
a) CREATE
b) SET
c) SETUP
d) LINK
View Answer
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
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.
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
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
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.
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
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
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.
10. Which statement makes changes to the database’s global attributes?
a) CHANGE
b) ALTER
c) ALTERNATE
d) UPDATE
View Answer
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.
- Practice Programming MCQs
- Apply for Programming Internship
- Check Information Technology Books
- Check MySQL Books