Mongodb Classroom image

Anil  Bist / Professional / DataBase

To post your Question Join Classroom
Lesson Topics's No:-  |1 | 2|Last
Lessons:-Create a Collection


Create a Collection

First Select Or Create a database.

> use mydb
switched to db mydb


Using  db.createCollection ( "yourCollectionName" method you can explicitly create Collection.

>  db. createCollection ( "newCollection1" )
"ok" : 1


Using  show collections  command see all collections in the database.

>  show  collections
system. indexes


The  db.createCollection()  method has the following parameters:

Parameter         Type              Description
name                string               The name of the collection to create.
options              document         Optional. Configuration options for creating a  capped collection  or for preallocating space in a new collection.


The fllowing example shows the syntax of  createCollection()  method with few important options

>db. createCollection ( "newCollection4", {capped : true, autoIndexId : true,  size  :  6142800,  max :
10000 })
{ "ok"  : 1  }


Anil  Bist

Skills    Mongodb

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a


  Students (0)