CouchDB – Create Database

To create a database in CouchDB, you can either use CouchDB Web Interface or REST API.

Create Database via REST API

Send a HTTP PUT 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 create a database with name cars.

The resulting request URL that we have to use for PUT request will become,

http://127.0.0.1:5984/cars/

We will use Postman, to trigger a PUT request with the URL to create CouchDB Database. You can use any other CLI or GUI tool of your choice.

CouchDB - REST API - Create Database

Let us check if the database is created.

Send a HTTP GET Request with the same URL as above.

CouchDB - View Database

The database has been created and present. You get all the information about the database in the response.

Create Database via CouchDB Web Interface

You can also create 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/.

Click on Create Database button highlighted in green in the below screenshot.

CouchDB - Create Database using Web Interface

A pop appears under Create Database. Enter the new database name and click on Create button.

CoucuDB - Create Database - Enter database name

Once you click on the Create button, if everything is good, a new database is created.

In the database list, you should see the new database created.

CouchDB - New Database in the List

Summary

In this CouchDB Tutorial, we learned to create a new database via HTTP REST API and Web Interface provided by CouchDB.