ClickHouse/docs/en/sql-reference/statements/exchange.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
948 B
Markdown
Raw Normal View History

2021-08-01 13:02:35 +00:00
---
2022-08-28 14:53:34 +00:00
slug: /en/sql-reference/statements/exchange
sidebar_position: 49
sidebar_label: EXCHANGE
2021-08-01 13:02:35 +00:00
---
2022-06-02 10:55:18 +00:00
# EXCHANGE Statement
2021-08-01 13:02:35 +00:00
2021-08-01 16:17:50 +00:00
Exchanges the names of two tables or dictionaries atomically.
This task can also be accomplished with a [RENAME](./rename.md) query using a temporary name, but the operation is not atomic in that case.
2021-08-01 13:02:35 +00:00
:::note
The `EXCHANGE` query is supported by the [Atomic](../../engines/database-engines/atomic.md) database engine only.
:::
2021-08-01 13:02:35 +00:00
**Syntax**
```sql
2022-07-06 23:41:01 +00:00
EXCHANGE TABLES|DICTIONARIES [db0.]name_A AND [db1.]name_B [ON CLUSTER cluster]
2021-08-01 13:02:35 +00:00
```
2022-06-02 10:55:18 +00:00
## EXCHANGE TABLES
2021-08-01 13:02:35 +00:00
2021-08-01 16:17:50 +00:00
Exchanges the names of two tables.
2021-08-01 13:02:35 +00:00
**Syntax**
```sql
2022-07-06 23:41:01 +00:00
EXCHANGE TABLES [db0.]table_A AND [db1.]table_B [ON CLUSTER cluster]
2021-08-01 13:02:35 +00:00
```
2022-06-02 10:55:18 +00:00
## EXCHANGE DICTIONARIES
2021-08-01 13:02:35 +00:00
2021-08-01 16:17:50 +00:00
Exchanges the names of two dictionaries.
2021-08-01 13:02:35 +00:00
**Syntax**
```sql
2022-07-06 23:41:01 +00:00
EXCHANGE DICTIONARIES [db0.]dict_A AND [db1.]dict_B [ON CLUSTER cluster]
2021-08-01 13:02:35 +00:00
```
**See Also**
- [Dictionaries](../../sql-reference/dictionaries/index.md)