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

43 lines
893 B
Markdown
Raw Normal View History

2021-08-01 13:02:35 +00:00
---
toc_priority: 49
toc_title: EXCHANGE
---
# EXCHANGE Statement {#exchange}
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 "Note"
2021-08-01 16:17:50 +00:00
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)