mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 05:03:20 +00:00
5f53df7dbe
Allow `ATTACH TABLE [db.]name` if the table was previously detached, an the table structure can be read from disk. This makes reattaching tables less cumbersome: ``` CREATE TABLE test.t (x UInt8) ENGINE = Null; DETACH TABLE test.t; ATTACH TABLE test.t; ```
24 lines
590 B
SQL
24 lines
590 B
SQL
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();
|
|
|
|
CREATE MATERIALIZED VIEW test.mv TO test.dst AS SELECT * FROM test.src;
|
|
INSERT INTO test.src VALUES (1), (2);
|
|
|
|
-- Detach MV and see if the data is still readable
|
|
DETACH TABLE test.mv;
|
|
SELECT * FROM test.dst;
|
|
|
|
-- Reattach MV (shortcut)
|
|
ATTACH TABLE test.mv;
|
|
|
|
-- Drop the MV and see if the data is still readable
|
|
DROP TABLE test.mv;
|
|
SELECT * FROM test.dst;
|
|
|
|
DROP TABLE test.src;
|
|
DROP TABLE test.dst;
|