亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

MongoDB 刪除數(shù)據(jù)庫

在本章中,我們將看到如何使用MongoDB命令刪除數(shù)據(jù)庫。

dropDatabase()方法

db.dropDatabase()命令用于刪除 MongoDB 現(xiàn)有數(shù)據(jù)庫。

語法

dropDatabase()命令的基本語法如下-

db.dropDatabase()

這將刪除所選的數(shù)據(jù)庫。如果您尚未選擇任何數(shù)據(jù)庫,則它將刪除默認(rèn)的“test”數(shù)據(jù)庫。

在線示例

首先,使用命令 show dbs 檢查可用數(shù)據(jù)庫的列表

>show dbs
local      0.78125GB
mydb       0.23012GB
test       0.23012GB
>

如果要刪除新數(shù)據(jù)庫<mydb>,則使用 dropDatabase()命令如下:

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

現(xiàn)在檢查數(shù)據(jù)庫列表。

>show dbs
local      0.78125GB
test       0.23012GB
>