Language
C# Java
Article For
3.5

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