JDBC

    To implement the JDBC connection, ClickHouse uses the separate program clickhouse-jdbc-bridge that should run as a daemon.

    This engine supports the data type.

    • — URI or name of an external DBMS.

      URI Format: jdbc:<driver_name>://<host_name>:<port>/?user=<username>&password=<password>.
      Example for MySQL: jdbc:mysql://localhost:3306/?user=root&password=root.

    • external_table — Name of the table in external_database or a select query like select * from table1 where column1=1.

    Creating a table in MySQL server by connecting directly with it’s console client:

    1. mysql> CREATE TABLE `test`.`test` (
    2. -> `int_id` INT NOT NULL AUTO_INCREMENT,
    3. -> `int_nullable` INT NULL DEFAULT NULL,
    4. -> `float_nullable` FLOAT NULL DEFAULT NULL,
    5. -> PRIMARY KEY (`int_id`));
    6. Query OK, 0 rows affected (0,09 sec)
    7. mysql> insert into test (`int_id`, `float`) VALUES (1,2);
    8. Query OK, 1 row affected (0,00 sec)
    9. mysql> select * from test;
    10. +------+----------+-----+----------+
    11. +------+----------+-----+----------+
    12. | 1 | NULL | 2 | NULL |
    13. +------+----------+-----+----------+
    14. 1 row in set (0,00 sec)
    1. SELECT *
    2. FROM jdbc_table
    1. INSERT INTO jdbc_table(`int_id`, `float`)
    2. SELECT toInt32(number), toFloat32(number * 1.0)
    3. FROM system.numbers