Skip to main content

Operations: Server: How to delete a database?

This operation is used to delete databases from a server, with a possibility to remove all the data from hard drive.

Syntax

public DeleteDatabasesOperation(
string databaseName,
bool hardDelete,
string fromNode = null,
TimeSpan? timeToWaitForConfirmation = null)
{
}

public DeleteDatabasesOperation(DeleteDatabasesOperation.Parameters parameters)
{
}

public class Parameters
{
public string[] DatabaseNames { get; set; }

public bool HardDelete { get; set; }

public string[] FromNodes { get; set; }

public TimeSpan? TimeToWaitForConfirmation { get; set; }
}
Parameters
DatabaseNamestringName of a database to delete
HardDeleteboolShould all data be removed (data files, indexing files, etc.).
FromNodestringRemove the database just from a specific node. Default: null which would delete from all
TimeToWaitForConfirmationTimeSpanTime to wait for confirmation. Default: null will user server default (15 seconds)

Example I

var parameters = new DeleteDatabasesOperation.Parameters
{
DatabaseNames = new[] { "MyNewDatabase", "OtherDatabaseToDelete" },
HardDelete = true,
FromNodes = new[] { "A", "C" }, // optional
TimeToWaitForConfirmation = TimeSpan.FromSeconds(30) // optional
};
store.Maintenance.Server.Send(new DeleteDatabasesOperation(parameters));

Example II

In order to delete just one database from a server, you can also use this simplified constructor

store.Maintenance.Server.Send(new DeleteDatabasesOperation("MyNewDatabase", hardDelete: true, fromNode: null, timeToWaitForConfirmation: null));