MongoDB MCQ Questions - Database
This section focuses on "Database". These Multiple Choice Questions (MCQs) should be practiced to improve the MongoDB skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. MongoDB ______ is used to create database.
A. create database_name
B. use database_name
C. insert database_name
D. show database_name
View Answer
Ans : B
Explanation: MongoDB use DATABASE_NAME is used to create database.
2. use database_name command will create a new database if it doesn't exist, otherwise it will return the existing database.
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, use database_name command will create a new database if it doesn't exist, otherwise it will return the existing database.
3. In MongoDB default database is ________.
A. local
B. mydb
C. test
D. temp
View Answer
Ans : C
Explanation: In MongoDB default database is test.
4. If you didn't create any database, then collections will be stored in _______ database.
A. local
B. mydb
C. temp
D. test
View Answer
Ans : D
Explanation: If you didn't create any database, then collections will be stored in test database.
5. MongoDB ___________ command is used to drop a existing database.
A. db.drop()
B. db.dropDatabase()
C. db.deleteDatabase()
D. db.delete()
View Answer
Ans : B
Explanation: MongoDB db.dropDatabase() command is used to drop a existing database.
6. If you have not selected any database, then it will delete _________ database.
A. local
B. mydb
C. temp
D. test
View Answer
Ans : D
Explanation: If you have not selected any database, then it will delete default test database.
7. Does we need to use "use database_name" before dropping database?
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, we need to use "use database_name" before dropping database
8. How many database present after mondb installation?
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : B
Explanation: local and test this two database present after mongodb install.
9. What will be mongodb output when we use "use mydb" command?
A. created db mydb
B. new db mydb
C. switched to db mydb
D. None of the above
View Answer
Ans : C
Explanation: switched to db mydb will be mongodb output when we use "use mydb" command.
10. If you created database (mydb) is not present in list. To display database, you need to insert at least one document into it.
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, Your created database (mydb) is not present in list. To display database, you need to insert at least one document into it.
Discussion