MongoDB - drop a database

Professionaluser
Posted by Professionaluser under Sql Server category on | Points: 40 | Views : 210
The following command is used to drop a database in MongoDB

>db.DropDatabase() 


Above command drops the currently selected database. If you have not selected any database then it deletes the default database (i.e. test)

MongoDB commands:
>use TestDatabase
switched to db TestDatabase
>db.dropDatabase()
>{ "dropped" : "TestDatabase", "ok" : 1 }
>


SQL Server throws an error if you try to drop a database that is currently being used...

Use DBName
GO
DROP DATABASE DBName

Error:
Msg 3702, Level 16, State 3, Line 1
Cannot drop database "DBName" because it is currently in use.

Comments or Responses

Posted by: Bhuvanesh6 on: 7/31/2016 Level:Starter | Status: [Member] | Points: 10
Good one

Login to post response