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

> توثيق عبارة EXCHANGE

# عبارة EXCHANGE

يبدّل أسماء جدولين أو قاموسين تبديلًا ذريًا.
يمكن أيضًا تنفيذ هذه المهمة باستخدام استعلام [`RENAME`](/ar/reference/statements/rename) مع اسم مؤقت، لكن العملية في هذه الحالة لا تكون ذرية.

<Note>
  لا يدعم استعلام `EXCHANGE` إلا محركا قاعدة البيانات [`Atomic`](/ar/reference/engines/database-engines/atomic) و[`Shared`](/ar/products/cloud/features/infrastructure/shared-catalog#shared-database-engine).
</Note>

**الصيغة**

```sql theme={null}
EXCHANGE TABLES|DICTIONARIES [db0.]name_A AND [db1.]name_B [ON CLUSTER cluster]
```

<div id="exchange-tables">
  ## EXCHANGE TABLES
</div>

يبدّل اسمي جدولين.

**الصيغة**

```sql theme={null}
EXCHANGE TABLES [db0.]table_A AND [db1.]table_B [ON CLUSTER cluster]
```

<div id="exchange-multiple-tables">
  ### EXCHANGE عدة جداول
</div>

يمكنك إجراء EXCHANGE لعدة أزواج من الجداول ضمن استعلام واحد، مع فصلها بفواصل.

<Note>
  عند إجراء EXCHANGE لعدة أزواج من الجداول، تُنفَّذ عمليات التبديل **بالتتابع، وليس بشكل ذرّي**. وإذا حدث خطأ أثناء العملية، فقد يكون قد تم تبديل بعض أزواج الجداول، بينما لم يُبدَّل بعضها الآخر.
</Note>

**مثال**

```sql title="Query" theme={null}
-- Create tables
CREATE TABLE a (a UInt8) ENGINE=Memory;
CREATE TABLE b (b UInt8) ENGINE=Memory;
CREATE TABLE c (c UInt8) ENGINE=Memory;
CREATE TABLE d (d UInt8) ENGINE=Memory;

-- Exchange two pairs of tables in one query
EXCHANGE TABLES a AND b, c AND d;

SHOW TABLE a;
SHOW TABLE b;
SHOW TABLE c;
SHOW TABLE d;
```

```sql title="Response" theme={null}
-- Now table 'a' has the structure of 'b', and table 'b' has the structure of 'a'
┌─statement──────────────┐
│ CREATE TABLE default.a↴│
│↳(                     ↴│
│↳    `b` UInt8         ↴│
│↳)                     ↴│
│↳ENGINE = Memory        │
└────────────────────────┘
┌─statement──────────────┐
│ CREATE TABLE default.b↴│
│↳(                     ↴│
│↳    `a` UInt8         ↴│
│↳)                     ↴│
│↳ENGINE = Memory        │
└────────────────────────┘

-- Now table 'c' has the structure of 'd', and table 'd' has the structure of 'c'
┌─statement──────────────┐
│ CREATE TABLE default.c↴│
│↳(                     ↴│
│↳    `d` UInt8         ↴│
│↳)                     ↴│
│↳ENGINE = Memory        │
└────────────────────────┘
┌─statement──────────────┐
│ CREATE TABLE default.d↴│
│↳(                     ↴│
│↳    `c` UInt8         ↴│
│↳)                     ↴│
│↳ENGINE = Memory        │
└────────────────────────┘
```

<div id="exchange-dictionaries">
  ## EXCHANGE DICTIONARIES
</div>

يبدّل أسماء قاموسين.

**الصيغة**

```sql theme={null}
EXCHANGE DICTIONARIES [db0.]dict_A AND [db1.]dict_B [ON CLUSTER cluster]
```

**راجع أيضًا**

* [القواميس](/ar/reference/statements/create/dictionary)
