2017-10-21 20:08:49 +00:00
|
|
|
DROP TABLE IF EXISTS test.src;
|
|
|
|
DROP TABLE IF EXISTS test.dst;
|
2019-04-18 18:48:04 +00:00
|
|
|
DROP TABLE IF EXISTS test.mv_00508;
|
2017-10-21 20:08:49 +00:00
|
|
|
|
|
|
|
CREATE TABLE test.src (x UInt8) ENGINE = Null;
|
2017-10-30 12:14:36 +00:00
|
|
|
CREATE TABLE test.dst (x UInt8) ENGINE = Memory;
|
2017-10-21 20:08:49 +00:00
|
|
|
|
2017-10-30 17:53:01 +00:00
|
|
|
USE test;
|
|
|
|
|
2019-04-18 18:48:04 +00:00
|
|
|
CREATE MATERIALIZED VIEW test.mv_00508 TO dst AS SELECT * FROM src;
|
2017-10-30 17:53:01 +00:00
|
|
|
|
|
|
|
INSERT INTO src VALUES (1), (2);
|
2019-04-18 18:48:04 +00:00
|
|
|
SELECT * FROM test.mv_00508 ORDER BY x;
|
2017-10-21 20:08:49 +00:00
|
|
|
|
2017-10-21 20:38:39 +00:00
|
|
|
-- Detach MV and see if the data is still readable
|
2019-04-18 18:48:04 +00:00
|
|
|
DETACH TABLE test.mv_00508;
|
2017-11-01 04:11:01 +00:00
|
|
|
SELECT * FROM dst ORDER BY x;
|
2017-10-30 17:53:01 +00:00
|
|
|
|
|
|
|
USE default;
|
2017-10-21 20:38:39 +00:00
|
|
|
|
|
|
|
-- Reattach MV (shortcut)
|
2019-04-18 18:48:04 +00:00
|
|
|
ATTACH TABLE test.mv_00508;
|
2017-10-21 20:38:39 +00:00
|
|
|
|
2017-10-30 17:53:01 +00:00
|
|
|
INSERT INTO test.src VALUES (3);
|
|
|
|
|
2019-04-18 18:48:04 +00:00
|
|
|
SELECT * FROM test.mv_00508 ORDER BY x;
|
2017-10-30 17:53:01 +00:00
|
|
|
|
2017-10-21 20:08:49 +00:00
|
|
|
-- Drop the MV and see if the data is still readable
|
2019-04-18 18:48:04 +00:00
|
|
|
DROP TABLE test.mv_00508;
|
2017-11-01 04:11:01 +00:00
|
|
|
SELECT * FROM test.dst ORDER BY x;
|
2017-10-21 20:08:49 +00:00
|
|
|
|
|
|
|
DROP TABLE test.src;
|
|
|
|
DROP TABLE test.dst;
|