2021-08-01 13:02:35 +00:00
|
|
|
---
|
2022-04-09 13:29:05 +00:00
|
|
|
sidebar_position: 49
|
|
|
|
sidebar_label: EXCHANGE
|
2021-08-01 13:02:35 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# EXCHANGE Statement {#exchange}
|
|
|
|
|
2021-08-01 16:17:50 +00:00
|
|
|
Exchanges the names of two tables or dictionaries atomically.
|
2021-08-03 20:05:32 +00:00
|
|
|
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
|
|
|
|
2022-04-09 13:29:05 +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
|
|
|
|
EXCHANGE TABLES|DICTIONARIES [db0.]name_A AND [db1.]name_B
|
|
|
|
```
|
|
|
|
|
|
|
|
## EXCHANGE TABLES {#exchange_tables}
|
|
|
|
|
2021-08-01 16:17:50 +00:00
|
|
|
Exchanges the names of two tables.
|
2021-08-01 13:02:35 +00:00
|
|
|
|
|
|
|
**Syntax**
|
|
|
|
|
|
|
|
```sql
|
|
|
|
EXCHANGE TABLES [db0.]table_A AND [db1.]table_B
|
|
|
|
```
|
|
|
|
|
|
|
|
## EXCHANGE DICTIONARIES {#exchange_dictionaries}
|
|
|
|
|
2021-08-01 16:17:50 +00:00
|
|
|
Exchanges the names of two dictionaries.
|
2021-08-01 13:02:35 +00:00
|
|
|
|
|
|
|
**Syntax**
|
|
|
|
|
|
|
|
```sql
|
|
|
|
EXCHANGE DICTIONARIES [db0.]dict_A AND [db1.]dict_B
|
|
|
|
```
|
|
|
|
|
|
|
|
**See Also**
|
|
|
|
|
|
|
|
- [Dictionaries](../../sql-reference/dictionaries/index.md)
|