ALTER TABLE ATTACH PARTITION
Restores one or more partitions to the table where they have been detached from by using the SQL ALTER TABLE DETACH PARTITION keyword. The operation scans the table partition files and rename the selected partition directories, so that these partitions become accessible.
This feature is part of the manual S3/cold storage solution, allowing restoring data manually.
Syntax#
Example#
Assuming the QuestDB data directory is /var/lib/questdb/db, for a table x with AWS S3 for cold storage:
Copy files from S3:
Execute the SQL
ALTER TABLE ATTACH PARTITIONcommand:After the SQL is executed, the partitions will be available to reads.
info
- The SQL reference to the partitions does not include the suffix
.attachable. - The
WHEREclause is not supported when attaching partitions.
Limitation#
- S3/Cold storage interaction is manual.
- Partition can only be attached to the same table it was detached from. The table name must be the same. Moving partitions between tables or database instances is not supported.
- The operation will fail if a partition already exists. We are working on a functionality to allow merging data in the same partition for attaching.