Skip to content

Instantly share code, notes, and snippets.

@alexey-milovidov
Created October 12, 2018 01:27
Show Gist options
  • Select an option

  • Save alexey-milovidov/c31b37f56114b822c7fdcf21d8557c9d to your computer and use it in GitHub Desktop.

Select an option

Save alexey-milovidov/c31b37f56114b822c7fdcf21d8557c9d to your computer and use it in GitHub Desktop.
$ docker run --network host --name mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7
$ mysql -uroot --password=my-secret-pw --host=127.0.0.1
CREATE DATABASE test_dictionary;
CREATE TABLE test_dictionary.RefProfit
(
sourceId int(11) NOT NULL,
money decimal(5,5) unsigned NOT NULL,
dateStart date NOT NULL DEFAULT '1970-01-01',
dateEnd date NOT NULL DEFAULT '1970-01-01',
KEY dateStart (`dateStart`,`dateEnd`),
KEY sourceId (`sourceId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
milovidov@milovidov-Latitude-E7470:~/work/ClickHouse/dbms/programs/server$ cat mysql_range_dictionary.xml
<dictionaries>
<dictionary>
<name>mysql_range</name>
<source>
<mysql>
<replica>
<priority>1</priority>
<host>127.0.0.1</host>
<port>3306</port>
</replica>
<user>root</user>
<password>my-secret-pw</password>
<db>test_dictionary</db>
<table>RefProfit</table>
</mysql>
</source>
<lifetime>
<min>0</min>
<max>0</max>
</lifetime>
<layout>
<range_hashed />
</layout>
<structure>
<id>
<name>sourceId</name>
</id>
<range_min>
<name>dateStart</name>
</range_min>
<range_max>
<name>dateEnd</name>
</range_max>
<attribute>
<name>money</name>
<type>Float32</type>
<null_value>0.0</null_value>
</attribute>
</structure>
</dictionary>
</dictionaries>
$ clickhouse-client
SELECT * FROM system.dictionaries;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment