MySQL database engine
Allows to connect to databases on a remote MySQL server and perform INSERT and SELECT queries to exchange data between ClickHouse and MySQL.
The MySQL database engine translate queries to the MySQL server so you can perform operations such as SHOW TABLES or SHOW CREATE TABLE.
You cannot perform the following queries:
RENAMECREATE TABLEALTER
Creating a database
Engine Parameters
host:port— MySQL server address.database— Remote database name.user— MySQL user.password— User password.
Settings
enable_compression
Enables zlib compression for the MySQL protocol connection. When set to 1, ClickHouse requests protocol-level compression from the MySQL server.
Default value: 0.
Example:
Data types support
| MySQL | ClickHouse |
|---|---|
| UNSIGNED TINYINT | UInt8 |
| TINYINT | Int8 |
| UNSIGNED SMALLINT | UInt16 |
| SMALLINT | Int16 |
| UNSIGNED INT, UNSIGNED MEDIUMINT | UInt32 |
| INT, MEDIUMINT | Int32 |
| UNSIGNED BIGINT | UInt64 |
| BIGINT | Int64 |
| FLOAT | Float32 |
| DOUBLE | Float64 |
| DATE | Date |
| DATETIME, TIMESTAMP | DateTime |
| BINARY | FixedString |
| POINT | Point |
| LINESTRING | LineString |
| POLYGON | Polygon |
| MULTILINESTRING | MultiLineString |
| MULTIPOLYGON | MultiPolygon |
| GEOMETRY | Geometry |
The conversion of the spatial types (other than POINT, which is always converted) is controlled by the geometry flag of the mysql_datatypes_support_level setting, enabled by default. The generic GEOMETRY column type is mapped to the umbrella Geometry type (a Variant over the concrete geometric types). Because such a column can hold a value of any subtype, reading a value whose subtype has no ClickHouse counterpart (MULTIPOINT, GEOMETRYCOLLECTION) throws an exception at read time; this incompatibility is accepted in exchange for a proper geometric type. Columns declared with the MULTIPOINT or GEOMETRYCOLLECTION type are converted into String (the raw WKB) like all other MySQL data types.
Nullable is supported.
Global variables support
For better compatibility you may address global variables in MySQL style, as @@identifier.
These variables are supported:
versionmax_allowed_packet
By now these variables are stubs and don't correspond to anything.
Example:
Examples of use
Table in MySQL:
Database in ClickHouse, exchanging data with the MySQL server: