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

Syntax

Basic syntax of use DATABASE statement is:

use DATABASE_NAME

Example

If you want to create a database with name mydb, then use DATABASE statement would be:

> 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

Words from our clients

 

Tell Us About Your Project

We’ve done lot’s of work, Let’s Check some from here