打開Fauxton網(wǎng)址:http://localhost:5984/_utils/ ,如下圖所示 -
單擊其中一個數(shù)據(jù)庫:yiibai_db
,將看到這個數(shù)據(jù)庫所有信息,并點擊刪除(“Delete Database…”)選項來刪除當(dāng)前數(shù)據(jù)庫(yiibai_db
),如下圖中所示 -
它將顯示一個彈出消息,要求確認數(shù)據(jù)庫名稱。如下圖中所示 -
點擊“Delete”后,數(shù)據(jù)庫就被刪除了,列表中再沒有數(shù)據(jù)庫(yiibai_db
)。如下圖中所示 -
CouchDB可通過使用cURL實用程序向服務(wù)器發(fā)送HTTP請求DELETE
方法來刪除數(shù)據(jù)庫。
語法:
curl -H 'Content-Type: application/json' -X DELETE http://localhost:5984/database_name
注意:HTTP服務(wù)器通信使用
-X
選項時,用于指定HTTP的自定義請求方法。要刪除數(shù)據(jù)庫,請通過指定數(shù)據(jù)庫將URL發(fā)送到服務(wù)器。
示例:
要刪除一個名稱為“yiibai_db2
”的數(shù)據(jù)庫。
使用以下命令:
curl -H 'Content-Type: application/json' -X DELETE http://localhost:5984/yiibai_db2
執(zhí)行結(jié)果:
yiibai@ubuntu:~$ curl -H 'Content-Type: application/json' -X DELETE http://localhost:5984/yiibai_db2
{"ok":true}
yiibai@ubuntu:~$
驗證刪除結(jié)果
可以使用以下命令驗證數(shù)據(jù)庫是否被刪除:
yiibai@ubuntu:~$ curl -X GET http://localhost:5984/_all_dbs
["_replicator","_users"]
yiibai@ubuntu:~$
如上面返回的結(jié)果集中,數(shù)據(jù)庫:yiibai_db2
已經(jīng)被刪除了。