CouchDB – Delete Database
To delete a database in CouchDB, you can either use CouchDB Web Interface or REST API.
Delete Database via REST API
Send a HTTP DELETE request with the following URL.
http://hostname/database_name/
We have our CouchDB running in our localhost. Hence, we shall use 127.0.0.1:5984
as hostname.
Let us delete the CouchDB database named cars
.
The resulting request URL that we have to use for DELETE request will become,
http://127.0.0.1:5984/cars/
We will use Postman, to trigger a DELETE request with the URL to delete CouchDB Database. You can use any other CLI or GUI tool of your choice.
Let us check if the database is deleted.
Send a HTTP GET Request with the same URL as above.
The database has been deleted and hence not present.
Delete Database via CouchDB Web Interface
You can also delete database in CouchDB using Web Interface.
Open URL http://hostname/_utils/
in your browser. In this example, the URL will be http://127.0.0.1:5984/_utils/
.
In this example, we will delete the database named mobiles
.
Under Databases tab, click on the delete icon shown against the database to be deleted. The delete icon is marked in the following screenshot.
Once you click on the Delete button, you will be asked to confirm deletion as shown below. Enter the database name. Delete Database button will be enabled. Click on this button.
After you click on the Delete Database
button, you should see a message that the database has been deleted, as shown in the following picture.
Summary
In this CouchDB Tutorial, we learned to delete a database via HTTP REST API and Web Interface provided by CouchDB.