ClickHouse/dbms/tests/queries/0_stateless/00508_materialized_view_to.sql

34 lines
704 B
MySQL
Raw Normal View History

DROP TABLE IF EXISTS test.src;
DROP TABLE IF EXISTS test.dst;
DROP TABLE IF EXISTS test.mv;
CREATE TABLE test.src (x UInt8) ENGINE = Null;
CREATE TABLE test.dst (x UInt8) ENGINE = Memory;
USE test;
CREATE MATERIALIZED VIEW mv TO dst AS SELECT * FROM src;
INSERT INTO src VALUES (1), (2);
2017-11-01 04:11:01 +00:00
SELECT * FROM mv ORDER BY x;
-- Detach MV and see if the data is still readable
DETACH TABLE mv;
2017-11-01 04:11:01 +00:00
SELECT * FROM dst ORDER BY x;
USE default;
-- Reattach MV (shortcut)
ATTACH TABLE test.mv;
INSERT INTO test.src VALUES (3);
2017-11-01 04:11:01 +00:00
SELECT * FROM test.mv ORDER BY x;
-- Drop the MV and see if the data is still readable
DROP TABLE test.mv;
2017-11-01 04:11:01 +00:00
SELECT * FROM test.dst ORDER BY x;
DROP TABLE test.src;
DROP TABLE test.dst;