On this page
AT MILESTONE and
AT TIME options are available only in the Premium and Dedicated editions as they enable PITR, which is a Premium/Dedicated feature.
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.
ATTACH DATABASE remote_database_name [AS new_database_name] [AT MILESTONE milestone_name | AT TIME attach_time]
A quoted string, which is the name of a milestone to restore to.
remote_is currently attached, it must be detached (using DETACH DATABASE) before it can be reattached.
AT TIMEattaches the database, with its contents restored to the specified point in time.
The specified time may be a
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.
AT TIMEare not specified, the database is attached at the latest state where all information is available for committed transactions.
You cannot specify both
ATTACH DATABASE remote_renames
database_ name AS new_ database_ name
new_, following the attach.
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 workspace, 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 workspace.
This command cannot be run on system databases.
ATTACH DATABASE db01;
ATTACH DATABASE db01 AT MILESTONE m01;
ATTACH DATABASE db01 AT TIME “2022-09-03 11:37:07”;
You can only attach a database to a workspace within a single workspace group.
A database cannot have more than one read-write attachment.
Databases with a large number of partitions cannot be attached to a small workspaces.
Here is an example of the error message when the total number of partitions is greater: "Creating or attaching a database with 32 total partitions to a cluster or workspace with 2 total cores is not supported.
To attach an existing database in the read-write mode to a workspace, connect to the target workspace and execute the following command:
ATTACH DATABASE db_name;
To attach an existing database to a workspace in the read-only mode, execute the following command:
ATTACH DATABASE db_name READ ONLY;
The read-only mode is mutually exclusive with the PITR options.
SHOW DATABASES only lists the databases that are attached to the current workspace.
Last modified: August 2, 2023