Échange de manière atomique les noms de deux tables ou dictionnaires.
Cette opération peut également être réalisée avec une requête RENAME utilisant un nom temporaire, mais dans ce cas, l’opération n’est pas atomique.
Syntaxe
EXCHANGE TABLES|DICTIONARIES [db0.]name_A AND [db1.]name_B [ON CLUSTER cluster]EXCHANGE TABLES
Échange les noms de deux tables.
Syntaxe
EXCHANGE TABLES [db0.]table_A AND [db1.]table_B [ON CLUSTER cluster]EXCHANGE DE PLUSIEURS TABLES
Vous pouvez échanger plusieurs paires de tables dans une seule requête en les séparant par des virgules.
Exemple
-- 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;-- Now table 'a' has the structure of 'b', and table 'b' has the structure of 'a'
┌EXCHANGE DICTIONARIES
Échange les noms de deux dictionnaires.
Syntaxe
EXCHANGE DICTIONARIES [db0.]dict_A AND [db1.]dict_B [ON CLUSTER cluster]Voir aussi