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?

  1. db.dropDatabase()
  2. db.createCollection()
  3. Both A. and B.
  4. 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.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.