Create Database in CouchDB

Create Database

In CouchDB, documents are stored in databases. Databases are thus outermost structure. To create databases in CouchDB one can either use the cURL utility or Fauxton web interface.

Using Fauxton:

  • Open the following link in a browser: http://127.0.0.1:5984/_utils/.
  • Click on the “Create Database” tab.
  • Write the database name to be created. For Example: ‘Company’
  • A message will be displayed on successful database creation.
  • Check the newly created database in the database tab.

Using cURL Utility:

Syntax:

curl -X PUT http://127.0.0.1:5984/database_name

Example:

curl -X PUT http://127.0.0.1:5984/company

Explanation:
A database named “company” is created. The server in response for a successful database creation will return a JSON document with content “ok”: true.

Verification:

List out all the existing databases using the below command:

curl -X GET http://127.0.0.1:5984/_all_dbs

Check Database Information:

Syntax: To retrieve the information about the database.

curl -X GET http://127.0.0.1:5984/database_name

Example:

curl -X GET http://127.0.0.1:5984/company

Explanation:

Here, we are retrieving information for a database named “company”.