Home »
MCQs »
MongoDB MCQs
Amongst which of the following is / are the command used to create collection in MongoDB?
30. Amongst which of the following is / are the command used to create collection in MongoDB?
- db.dropDatabase()
- db.createCollection()
- Both A. and B.
- None of the mentioned above
Answer: B) db.createCollection()
Explanation:
The db.createCollection (name, options) command is used to create a collection in MongoDB. Explanation: MongoDB uses the db.createCollection (name, options) command to create a collection. Normally, this is not necessary because MongoDB automatically creates collections when new documents are inserted into the database. db.createCollection is the command to use (name, options).
- Name: This is a string type that specifies the name of the collection that is going to be created.
- Options: The document type determines the amount of memory available and how the collection is indexed. It is a parameter that can be omitted.