ClickHouse/tests/queries/0_stateless/01914_exchange_dictionaries.sql

40 lines
1.2 KiB
MySQL
Raw Normal View History

2021-06-27 22:41:55 +00:00
DROP DATABASE IF EXISTS 01914_db;
CREATE DATABASE 01914_db ENGINE=Atomic;
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
DROP TABLE IF EXISTS 01914_db.table_1;
CREATE TABLE 01914_db.table_1 (id UInt64, value String) ENGINE=TinyLog;
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
DROP TABLE IF EXISTS 01914_db.table_2;
CREATE TABLE 01914_db.table_2 (id UInt64, value String) ENGINE=TinyLog;
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
INSERT INTO 01914_db.table_1 VALUES (1, 'Table1');
INSERT INTO 01914_db.table_2 VALUES (2, 'Table2');
2021-06-27 22:41:55 +00:00
DROP DICTIONARY IF EXISTS 01914_db.dictionary_1;
CREATE DICTIONARY 01914_db.dictionary_1 (id UInt64, value String)
2021-06-18 20:59:35 +00:00
PRIMARY KEY id
LAYOUT(DIRECT())
2021-06-27 22:41:55 +00:00
SOURCE(CLICKHOUSE(DB '01914_db' TABLE 'table_1'));
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
DROP DICTIONARY IF EXISTS 01914_db.dictionary_2;
CREATE DICTIONARY 01914_db.dictionary_2 (id UInt64, value String)
2021-06-18 20:59:35 +00:00
PRIMARY KEY id
LAYOUT(DIRECT())
2021-06-27 22:41:55 +00:00
SOURCE(CLICKHOUSE(DB '01914_db' TABLE 'table_2'));
2021-06-27 22:41:55 +00:00
SELECT * FROM 01914_db.dictionary_1;
SELECT * FROM 01914_db.dictionary_2;
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
EXCHANGE DICTIONARIES 01914_db.dictionary_1 AND 01914_db.dictionary_2;
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
SELECT * FROM 01914_db.dictionary_1;
SELECT * FROM 01914_db.dictionary_2;
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
DROP DICTIONARY 01914_db.dictionary_1;
DROP DICTIONARY 01914_db.dictionary_2;
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
DROP TABLE 01914_db.table_1;
DROP TABLE 01914_db.table_2;
2021-06-18 20:59:35 +00:00
2021-06-27 22:41:55 +00:00
DROP DATABASE 01914_db;