mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
34 lines
849 B
MySQL
34 lines
849 B
MySQL
|
DROP DATABASE IF EXISTS db_for_dict;
|
||
|
CREATE DATABASE db_for_dict;
|
||
|
|
||
|
CREATE TABLE db_for_dict.table_for_dict
|
||
|
(
|
||
|
key1 UInt64,
|
||
|
value String
|
||
|
)
|
||
|
ENGINE = Memory();
|
||
|
|
||
|
INSERT INTO db_for_dict.table_for_dict VALUES (1, 'Hello'), (2, 'World');
|
||
|
|
||
|
CREATE DICTIONARY db_for_dict.dict_with_hashed_layout
|
||
|
(
|
||
|
key1 UInt64,
|
||
|
value String
|
||
|
)
|
||
|
PRIMARY KEY key1
|
||
|
LAYOUT(HASHED)
|
||
|
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' DB 'db_for_dict'))
|
||
|
LIFETIME(MIN 1 MAX 10);
|
||
|
|
||
|
SELECT dictGet('db_for_dict.dict_with_hashed_layout', 'value', toUInt64(2));
|
||
|
|
||
|
DETACH DICTIONARY db_for_dict.dict_with_hashed_layout;
|
||
|
|
||
|
ATTACH DICTIONARY db_for_dict.dict_with_hashed_layout;
|
||
|
|
||
|
SHOW CREATE DICTIONARY db_for_dict.dict_with_hashed_layout;
|
||
|
|
||
|
SELECT dictGet('db_for_dict.dict_with_hashed_layout', 'value', toUInt64(1));
|
||
|
|
||
|
DROP DATABASE IF EXISTS db_for_dict;
|