ATTACH Statement

    Syntax

    The query does not create data on the disk, but assumes that data is already in the appropriate places, and just adds information about the table or the dictionary to the server. After executing the query, the server will know about the existence of the table or the dictionary.

    If a table was previously detached (DETACH query), meaning that its structure is known, you can use shorthand without defining the structure.

    Syntax

    1. ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster]

    If the table was detached permanently, it won’t be reattached at the server start, so you need to use query explicitly.

    The query creates a new table with provided structure and attaches table data from the provided directory in user_files.

    Syntax

    Example

    1. DROP TABLE IF EXISTS test;
    2. ATTACH TABLE test FROM '01188_attach/test' (s String, n UInt8) ENGINE = File(TSV);
    3. SELECT * FROM test;

    Result:

    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.

    Syntax

    Attaches a previously detached dictionary.