2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: no-parallel
|
|
|
|
|
2020-04-03 23:37:58 +00:00
|
|
|
DROP DATABASE IF EXISTS test_00508;
|
2020-02-11 18:05:08 +00:00
|
|
|
CREATE DATABASE test_00508;
|
2017-10-21 20:08:49 +00:00
|
|
|
|
2020-02-11 18:05:08 +00:00
|
|
|
USE test_00508;
|
2017-10-21 20:08:49 +00:00
|
|
|
|
2020-02-11 18:05:08 +00:00
|
|
|
CREATE TABLE src (x UInt8) ENGINE = Null;
|
|
|
|
CREATE TABLE dst (x UInt8) ENGINE = Memory;
|
|
|
|
|
|
|
|
CREATE MATERIALIZED VIEW mv_00508 TO dst AS SELECT * FROM src;
|
2017-10-30 17:53:01 +00:00
|
|
|
|
|
|
|
INSERT INTO src VALUES (1), (2);
|
2020-02-11 18:05:08 +00:00
|
|
|
SELECT * FROM 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
|
2020-02-11 18:05:08 +00:00
|
|
|
DETACH TABLE 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)
|
2020-02-11 18:05:08 +00:00
|
|
|
ATTACH TABLE test_00508.mv_00508;
|
2017-10-21 20:38:39 +00:00
|
|
|
|
2020-02-11 18:05:08 +00:00
|
|
|
INSERT INTO test_00508.src VALUES (3);
|
2017-10-30 17:53:01 +00:00
|
|
|
|
2020-02-11 18:05:08 +00:00
|
|
|
SELECT * FROM test_00508.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
|
2020-02-11 18:05:08 +00:00
|
|
|
DROP TABLE test_00508.mv_00508;
|
|
|
|
SELECT * FROM test_00508.dst ORDER BY x;
|
|
|
|
|
|
|
|
DROP TABLE test_00508.src;
|
|
|
|
DROP TABLE test_00508.dst;
|
2017-10-21 20:08:49 +00:00
|
|
|
|
2020-02-11 18:05:08 +00:00
|
|
|
DROP DATABASE test_00508;
|