You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Commands: How to create or delete database?

This article will describe the following commands that enable you to manage databases on a server:
- CreateDatabase
- DeleteDatabase

CreateDatabase

Used to create a new database on a server.

Syntax

curl \
	http://{serverName}/admin/databases/{databaseName} \
	-X PUT \
	-d @databaseDocument.txt

Request

Payload
DatabaseDocument
Query parameter Required Description
databaseName Yes Name of a database to created

Response

Status code Description
200 OK

Example

curl -X PUT "http://localhost:8080/admin/databases/NewDatabase" \
	-d "{\"SecuredSettings\":{},\"Settings\":{\"Raven/ActiveBundles\":\"PeriodicExport\",\"Raven/DataDir\":\"~//\"},\"Disabled\":false,\"Id\":\"NewDatabase\"}"
< HTTP/1.1 200 OK

DeleteDatabase

Used to delete a database from a server, with a possibility to remove all the data from hard drive.

Syntax

curl \
	http://{serverName}/admin/databases/{databaseName} \
		&hard-delete={hardDelete} \
	-X DELETE

Request

Query parameter Required Description
databaseName Yes Name of a database to delete
hardDelete No Should all data be removed (data files, indexing files, etc.). Default: false

Response

Status code Description
204 No Content

Example

curl -X PUT "http://localhost:8080/admin/databases/NewDatabase?hard-delete=true" \
< HTTP/1.1 204 No Content