0% found this document useful (0 votes)
15 views

CouchDB - Creating A Database

Uploaded by

vallalanikhil7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

CouchDB - Creating A Database

Uploaded by

vallalanikhil7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Page 1 of 3

CouchDB - Creating a Database


Database is the outermost data structure in CouchDB where your documents are stored.
You can create these databases using cURL utility provided by CouchDB, as well as Futon
the web interface of CouchDB.

Creating a Database using cURL Utility


You can create a database in CouchDB by sending an HTTP request to the server using PUT
method through cURL utility. Following is the syntax to create a database −

$ curl -X PUT http://127.0.0.1:5984/database name

Using −X we can specify HTTP custom request method to be used. In this case, we are
using PUT method. When we use the PUT operation/method, the content of the url specifies
the object name we are creating using HTTP request. Here we have to send the name of the
database using put request in the url to create a database.

Example
Using the above given syntax if you want to create a database with name my_database,
you can create it as follows

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


{
"ok":true
}

As a response the server will return you a JSON document with content “ok” − true
indicating the operation was successful.

Verification
Verify whether the database is created, by listing out all the databases as shown below. Here
you can observe the name of a newly created database, " my_database " in the list.

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

[ "_replicator " , " _users " , " my_database " ]

Creating a Database using Futon

https://w w w .tutorialspoint.com/couchdb/couchdb_creating_a_database.htm 1/3


Page 2 of 3

To create a database open the http://127.0.0.1:5984/_utils/. You will get an


Overview/index page of CouchDB as shown below.

In this page, you can see the list of databases in CouchDB, an option button Create
Database on the left hand side.

Now click on the create database link. You can see a popup window Create New
Databases asking for the database name for the new database. Choose any name
following the mentioned criteria. Here we are creating another database with name
tutorials_point. Click on the create button as shown in the following screenshot.

https://w w w .tutorialspoint.com/couchdb/couchdb_creating_a_database.htm 2/3


Page 3 of 3

https://w w w .tutorialspoint.com/couchdb/couchdb_creating_a_database.htm 3/3

You might also like