odbc
Returns table that is connected via ODBC.
Parameters:
connection_settings
— Name of the section with connection settings in theodbc.ini
file.external_database
— Name of a database in an external DBMS.external_table
— Name of a table in theexternal_database
.
To safely implement ODBC connections, ClickHouse uses a separate program clickhouse-odbc-bridge
. If the ODBC driver is loaded directly from clickhouse-server
, driver problems can crash the ClickHouse server. ClickHouse automatically starts clickhouse-odbc-bridge
when it is required. The ODBC bridge program is installed from the same package as the clickhouse-server
.
The fields with the NULL
values from the external table are converted into the default values for the base data type. For example, if a remote MySQL table field has the INT NULL
type it is converted to 0 (the default value for ClickHouse Int32
data type).
Usage Example
Getting data from the local MySQL installation via ODBC
This example is checked for Ubuntu Linux 18.04 and MySQL server 5.7.
Ensure that unixODBC and MySQL Connector are installed.
By default (if installed from packages), ClickHouse starts as user clickhouse
. Thus you need to create and configure this user in the MySQL server.
Then configure the connection in /etc/odbc.ini
.
You can check the connection using the isql
utility from the unixODBC installation.
Table in MySQL:
Retrieving data from the MySQL table in ClickHouse: