1 Answer

0 votes
by

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 as follows −

use DATABASE_NAME

Select a database :

If you want to use a database with name <myMangoDB>, then use DATABASE statement would be as follows −

>use myMangoDB
switched to db myMangoDB

To check your currently selected database, use the command db

>db
myMangoDB
...