Attaches a table or a dictionary, for example, when moving a database to another server. SyntaxDocumentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-sync-cloud-1778703015.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
ATTACH query, the server will know about the existence of the table, dictionary or database.
If a table was previously detached (DETACH query), meaning that its structure is known, you can use shorthand without defining the structure.
Attach Existing Table
SyntaxATTACH queries, which it simply runs at launch (with the exception of some system tables, which are explicitly created on the server).
If the table was detached permanently, it won’t be reattached at the server start, so you need to use ATTACH query explicitly.
Create New Table And Attach Data
With Specified Path to Table Data
The query creates a new table with provided structure and attaches table data from the provided directory inuser_files.
Syntax
With Specified Table UUID
This query creates a new table with provided structure and attaches data from the table with the specified UUID. It is supported by the Atomic database engine. SyntaxAttach MergeTree table as ReplicatedMergeTree
Allows to attach non-replicated MergeTree table as ReplicatedMergeTree. ReplicatedMergeTree table will be created with values ofdefault_replica_path and default_replica_name settings. It is also possible to attach a replicated table as a regular MergeTree.
Note that table’s data in ZooKeeper is not affected in this query. This means you have to add metadata in ZooKeeper using SYSTEM RESTORE REPLICA or clear it with SYSTEM DROP REPLICA ... FROM ZKPATH ... after attach.
If you are trying to add a replica to an existing ReplicatedMergeTree table, keep in mind that all the local data in converted MergeTree table will be detached.
Syntax