鍍金池/ 教程/ 數(shù)據(jù)庫/ CouchDB刪除數(shù)據(jù)庫
CouchDB刪除文檔
CouchDB修改文檔
CouchDB教程
CouchDB是什么?
CouchDB創(chuàng)建文檔
為什么使用CouchDB?
CouchDB創(chuàng)建數(shù)據(jù)庫
CouchDB安裝配置
CouchDB快速入門
CouchDB HTTP API
CouchDB刪除數(shù)據(jù)庫
CouchDB cURL
CouchDB與MongoDB比較
CouchDB的特點(diǎn)

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

CouchDB使用Fauxton刪除數(shù)據(jù)庫

打開Fauxton網(wǎng)址:http://localhost:5984/_utils/ ,如下圖所示 -

單擊其中一個數(shù)據(jù)庫:yiibai_db,將看到這個數(shù)據(jù)庫所有信息,并點(diǎn)擊刪除(“Delete Database…”)選項來刪除當(dāng)前數(shù)據(jù)庫(yiibai_db),如下圖中所示 -

它將顯示一個彈出消息,要求確認(rèn)數(shù)據(jù)庫名稱。如下圖中所示 -

點(diǎn)擊“Delete”后,數(shù)據(jù)庫就被刪除了,列表中再沒有數(shù)據(jù)庫(yiibai_db)。如下圖中所示 -

CouchDB使用cURL工具刪除數(shù)據(jù)庫

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)被刪除了。


上一篇:CouchDB HTTP API下一篇:CouchDB刪除文檔