ClickHouse/dbms/tests/queries/0_stateless/00824_indices_alter.sql

68 lines
1.8 KiB
MySQL
Raw Normal View History

2019-01-16 17:59:47 +00:00
DROP TABLE IF EXISTS test.minmax_idx;
DROP TABLE IF EXISTS test.minmax_idx2;
CREATE TABLE test.minmax_idx
(
u64 UInt64,
i32 Int32
) ENGINE = MergeTree()
ORDER BY u64;
INSERT INTO test.minmax_idx VALUES (1, 2);
ALTER TABLE test.minmax_idx ADD INDEX idx1 BY u64 * i32 TYPE minmax GRANULARITY 10;
2019-01-16 18:24:38 +00:00
ALTER TABLE test.minmax_idx ADD INDEX idx2 BY u64 + i32 TYPE minmax GRANULARITY 10;
ALTER TABLE test.minmax_idx ADD INDEX idx3 BY u64 - i32 TYPE minmax GRANULARITY 10 AFTER idx1;
2019-01-16 17:59:47 +00:00
SHOW CREATE TABLE test.minmax_idx;
2019-01-16 18:35:03 +00:00
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
2019-01-16 18:35:03 +00:00
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
2019-01-16 18:24:38 +00:00
ALTER TABLE test.minmax_idx DROP INDEX idx1;
2019-01-16 17:59:47 +00:00
SHOW CREATE TABLE test.minmax_idx;
2019-01-16 18:35:03 +00:00
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
ALTER TABLE test.minmax_idx DROP INDEX idx2;
2019-01-16 18:35:03 +00:00
ALTER TABLE test.minmax_idx DROP INDEX idx3;
2019-01-16 17:59:47 +00:00
SHOW CREATE TABLE test.minmax_idx;
ALTER TABLE test.minmax_idx ADD INDEX idx1 BY u64 * i32 TYPE minmax GRANULARITY 10;
SHOW CREATE TABLE test.minmax_idx;
2019-01-16 18:35:03 +00:00
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
CREATE TABLE test.minmax_idx2
(
u64 UInt64,
i32 Int32
) ENGINE = MergeTree()
2019-01-16 18:24:38 +00:00
ORDER BY u64
INDEXES idx1 BY u64 + i32 TYPE minmax GRANULARITY 10,
idx2 BY u64 * i32 TYPE minmax GRANULARITY 10;
2019-01-16 17:59:47 +00:00
INSERT INTO test.minmax_idx2 VALUES (1, 2);
INSERT INTO test.minmax_idx2 VALUES (1, 2);
2019-01-16 18:35:03 +00:00
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
ALTER TABLE test.minmax_idx2 DROP INDEX idx1, DROP INDEX idx2;
SHOW CREATE TABLE test.minmax_idx2;
2019-01-16 18:35:03 +00:00
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
DROP TABLE test.minmax_idx;
DROP TABLE test.minmax_idx2;