Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

EXCHANGE

يبدّل أسماء جدولين أو قاموسين تبديلًا ذريًا. يمكن أيضًا تنفيذ هذه المهمة باستخدام استعلام RENAME مع اسم مؤقت، لكن العملية في هذه الحالة لا تكون ذرية.

الصيغة

EXCHANGE TABLES|DICTIONARIES [db0.]name_A AND [db1.]name_B [ON CLUSTER cluster]

EXCHANGE TABLES

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

الصيغة

EXCHANGE TABLES [db0.]table_A AND [db1.]table_B [ON CLUSTER cluster]

EXCHANGE عدة جداول

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

مثال

Querysql
-- 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;
Responsesql
-- Now table 'a' has the structure of 'b', and table 'b' has the structure of 'a'

EXCHANGE DICTIONARIES

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

الصيغة

EXCHANGE DICTIONARIES [db0.]dict_A AND [db1.]dict_B [ON CLUSTER cluster]

راجع أيضًا

Navigation