WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

MongoDB - Create Database


MongoDB - Create Database : In this chapter how to create a database in MongoDB.

The use Command

MongoDB use DATABASE_NAME is used to create database. The command will create a new database if it doesn't exist,

Syntax

There are following Basic syntax of use DATABASE statement is as follows −
use DATABASE_NAME

Example

If you want to use 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, use the command show dbs.
>show dbs
local     0.78125GB
test      0.23012GB
Your created database (mydb) is not present in list. To display database, you need to insert at least one document into it.
>db.movie.insert({"name":"Welookups"})
>show dbs
local      0.78125GB
mydb       0.23012GB
test       0.23012GB




Welookups is optimized for learning.Copy right 2018 kumar aditya singh .
All Right Reserved and you agree to have read and accepted our term and condition.
All Rights Reserved.