0% found this document useful (0 votes)
16 views

Mongodb Creating Database & Collections:: Mydb Switched To DB Mydb

This tutorials helps a beginner to understand, what is a Database, collection. How to create a new database, collection etc
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Mongodb Creating Database & Collections:: Mydb Switched To DB Mydb

This tutorials helps a beginner to understand, what is a Database, collection. How to create a new database, collection etc
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

MongoDB

Creating Database & Collections:


If you want to create a database with name <mydb>, then use DATABASE statement would be
as follows:
>use mydb
switched to db mydb
To check your currently selected database use the command db
>db
mydb
If you want to check your databases list, then use the command show dbs.
>show dbs
local
test

0.78125GB
0.23012GB

Your created database (mydb) is not present in list. To display database you need to insert
atleast one document into it.
>db.movie.insert({"name":"tutorials point"})
>show dbs
local
mydb
test

0.78125GB
0.23012GB
0.23012GB

Here movie is the new collection name, (Table). Which will be created under Database mydb.
In mongodb default database is test. If you didn't create any database then collections will be
stored in test database.

You might also like