ATTACH DATABASE

Note

The AT MILESTONE and AT TIME options are available only in the Premium edition as they enable PITR, which is a Premium feature. For more information, see SingleStore DB Editions.

In the SingleStore Free version, this command is not supported.

Note

Prior to using this command, the enable_bottomlessengine variable must be set to ON (the default value).

Restores an unlimited storage database at a restore point and then brings the database online.

See Permissions Matrix for the permissions required to use this command.

Syntax

ATTACH DATABASE remote_database_name ON <object_store_settings> [AT MILESTONE milestone_name | AT TIME attach_time]

<object_store_settings>:
    <S3_object_store_configuration> |
    <AZURE_object_store_configuration> |
    <GCS_object_store_configuration>

<S3_object_store_configuration>:
    S3 { '<bucket-name>' | '<bucket-name/object-name>' | '<bucket-name/prefix/object-name>' }
      [CONFIG '<configuration_json>']
      CREDENTIALS '<credentials_json>'

<AZURE_object_store_configuration>:
    AZURE { '<container-name>' | '<container-name/object-name>' | '<container-name/prefix/object-name>' }
      [CONFIG '<configuration_json>']
      CREDENTIALS '<credentials_json>'

<GCS_object_store_configuration>: 
    GCS {'<bucket-name>' | '<bucket-name/path>' }
    [CONFIG '<configuration_json>']
    CREDENTIALS '<credentials_json>'

Note

Using GCS is currently a preview feature.

Arguments

attach_time

A DATETIME or DATETIME(6) literal.

milestone_name

A quoted string, which is the name of a milestone to restore to.

Remarks

  • If remote_database_name is currently attached, it must be detached (using DETACH DATABASE) before it can be reattached.

  • AT TIME attaches the database, with its contents restored to the specified point in time. The specified time may be a DATETIME or a DATETIME(6) literal. An error will be returned if you attempt to attach a database at time literal that is later than the time of the latest detach.

  • If AT MILESTONE and AT TIME are not specified, the database is attached at the latest state where all information is available for committed transactions.

  • If AT MILESTONE or AT TIME are specified, the restore point must be within the unlimited storage database retention period.

  • You cannot specify both AT MILESTONE and AT TIME.

  • remote_database_name of the attached database can be different than the remote_database_name used when the database was detached.

  • Attaching an unlimited storage database can be faster than restoring an equivalent local storage database. This is because an attach of an unlimited storage database does not copy all data to the cluster, as is the case with the restore of a local storage database. Note that after an unlimited storage database is attached, queries may be slower for some time until remote data is cached locally in the cluster.

  • This command cannot be run on system databases.