Add documentation for ATTACH DATABASE

This commit is contained in:
Dmitry Novik 2023-11-03 01:21:11 +01:00 committed by GitHub
parent 49d553369e
commit f6733ac7ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,10 +10,10 @@ Attaches a table or a dictionary, for example, when moving a database to another
**Syntax** **Syntax**
``` sql ``` sql
ATTACH TABLE|DICTIONARY [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] ... ATTACH TABLE|DICTIONARY|DATABASE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] ...
``` ```
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 `ATTACH` query, the server will know about the existence of the table or the dictionary. 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 specified table, dictionary or databse to the server. After executing the `ATTACH` query, the server will know about the existence of the table, dictionary or database.
If a table was previously detached ([DETACH](../../sql-reference/statements/detach.md) query), meaning that its structure is known, you can use shorthand without defining the structure. If a table was previously detached ([DETACH](../../sql-reference/statements/detach.md) query), meaning that its structure is known, you can use shorthand without defining the structure.
@ -79,3 +79,13 @@ Attaches a previously detached dictionary.
``` sql ``` sql
ATTACH DICTIONARY [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] ATTACH DICTIONARY [IF NOT EXISTS] [db.]name [ON CLUSTER cluster]
``` ```
## Attach Existing Database
Attaches a previously detached database.
**Syntax**
``` sql
ATTACH DATABASE [IF NOT EXISTS] name [ENGINE=<database engine>] [ON CLUSTER cluster]
```