-- 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'
┌─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 │
└────────────────────────┘