DETACH DATABASE

Note

Prior to using this command, the enable_bottomless engine variable must be set to ON (the default value). Also, the allow_point_in_time_attach engine variable must be set to ON (the default is OFF).

The DETACH DATABASE command takes an unlimited storage database offline.

Refer to the Permission Matrix for the required permissions.

Syntax

DETACH DATABASE remote_database_name [AT MILESTONE "milestone_name" | FORCE]

Arguments

milestone_name

A quoted string that specifies the milestone from which to detach the database.

FORCE

The FORCE argument allows you to terminate ongoing uploads to remote storage and forcibly detach the database. This can be useful in situations where, for example, the detach process is unable to upload blobs to remote storage or encounters a connection loss error - scenarios in which the database cannot be detached normally and the process may become stuck.

The FORCE option is applicable only for clusters using unlimited storage and is intended primarily for emergency recovery. It is not recommended for routine use.

When the FORCE argument is not included, all outstanding changes are uploaded into remote storage before detaching.

When the FORCE argument is included, SingleStore immediately stops all ongoing uploads and detaches the database. Any data not yet uploaded to remote storage, such as columnstore blobs, rowstore data, or logs, will be lost, resulting in potential data loss. Note that this operation only detaches the database, and does not drop or delete it.

To reattach the database, use the ATTACH DATABASE command. While SingleStore restores the database, any data that was not previously uploaded to remote storage will be missing after reattachment.

Remarks

  • If FORCE is not specified, the following apply:

    • A milestone (restore point) is implicitly created via the CREATE MILESTONE command.

    • While the milestone is being created, SingleStore uploads the remote database's local cluster data to remote storage which has not yet been synced.

    • If milestone_name is not specified, a name containing the current timestamp is automatically generated.

  • Once a database is detached, information about that database and its milestones is no longer visible in the MV_* views such as MV_MILESTONES and MV_BOTTOMLESS_DATABASE. The information is available again once the database is reattached.

  • After detaching a database, you can reattach the database using ATTACH DATABASE. The database can be reattached at a milestone or a specified point in time, using either the same database name or the one specified.

  • The BACKUP DATABASE command cannot be run on a detached database. To run the BACKUP DATABASE command, all the partitions of a database must be either in the online or replicating state.

  • This command cannot be run on system databases.

  • Refer to the Permission Matrix for the required permissions.

Example

DETACH DATABASE db AT MILESTONE "m";

Last modified:

Was this article helpful?