CouchDB Create DataBase
In CouchDB, the outermost structure where documents are stored is known as a database. CouchDB provides CURL utility to create a database. You can also use CouchDB's web interface Futon. Lets dive right in and create your first CouchDB DataBase, a simple contact database where you will store information about the address book and phone book.
NOTE : We are assuming that you have couchDB server installed and running on your local machine.
Creating a Database using cURL Utility
Creating a database is very simple - just type the command in your terminal window or command prompt. If you have to create a database then you must send an HTTP request to the server using the PUT method through the cURL utility. −
$ curl -X PUT http://127.0.0.1:5984/database-name
When we use the PUT method the URL specifies the object name we are creating using the HTTP request. To create a database we have to send the name of the database using the PUT request in the url.
Example :
The Example of the Create DataBase is −
Here you are requesting an HTTP PUT from the /contact resource of the CouchDB server. CouchDB translates this as "Create a new database named contact".
curl -X PUT http://127.0.0.1:5984/contacts { "ok":true }
When the database is created, CouchDB responds with the following JSON object.{"0k": true}. The previous message basically means that the operation was successful and there was no error in CouchDB process of creating a contact database.
Verification :
Now that you have created a database, let's ask CouchDB to specify which databases are currently available on the server. As you see there is a database named "contacts" in the list. So it is proved that the database has been created.
$ curl -X GET http://127.0.0.1:5984/_all_dbs [ " letsfindcourse " , " couch-db " , " contacts " ]
Visit :
Discussion