> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for RENAME Statement

# RENAME Statement

Renames databases, tables, or dictionaries. Several entities can be renamed in a single query.
Note that the `RENAME` query with several entities is non-atomic operation. To swap entities names atomically, use the [EXCHANGE](/reference/statements/exchange) statement.

**Syntax**

```sql theme={null}
RENAME [DATABASE|TABLE|DICTIONARY] name TO new_name [,...] [ON CLUSTER cluster]
```

<h2 id="rename-database">
  RENAME DATABASE
</h2>

Renames databases.

**Syntax**

```sql theme={null}
RENAME DATABASE atomic_database1 TO atomic_database2 [,...] [ON CLUSTER cluster]
```

<h2 id="rename-table">
  RENAME TABLE
</h2>

Renames one or more tables.

Renaming tables is a light operation. If you pass a different database after `TO`, the table will be moved to this database. However, the directories with databases must reside in the same file system. Otherwise, an error is returned.
If you rename multiple tables in one query, the operation is not atomic. It may be partially executed, and queries in other sessions may get `Table ... does not exist ...` error.

**Syntax**

```sql theme={null}
RENAME TABLE [db1.]name1 TO [db2.]name2 [,...] [ON CLUSTER cluster]
```

**Example**

```sql theme={null}
RENAME TABLE table_A TO table_A_bak, table_B TO table_B_bak;
```

And you can use a simpler sql:

```sql theme={null}
RENAME table_A TO table_A_bak, table_B TO table_B_bak;
```

<h2 id="rename-dictionary">
  RENAME DICTIONARY
</h2>

Renames one or several dictionaries. This query can be used to move dictionaries between databases.

**Syntax**

```sql theme={null}
RENAME DICTIONARY [db0.]dict_A TO [db1.]dict_B [,...] [ON CLUSTER cluster]
```

**See Also**

* [Dictionaries](/reference/statements/create/dictionary)
