CREATE EXTERNAL TABLE `baseall_oracle` (`k1` decimal(9, 3) NOT NULL COMMENT "",`k2` char(10) NOT NULL COMMENT "",`k3` datetime NOT NULL COMMENT "",`k5` varchar(20) NOT NULL COMMENT "",`k6` double NOT NULL COMMENT "") ENGINE=ODBCCOMMENT "ODBC"PROPERTIES ("host" = "192.168.0.1","port" = "8086","user" = "test","password" = "test","database" = "test","table" = "baseall","driver" = "Oracle 19 ODBC driver","odbc_type" = "oracle");
CREATE EXTERNAL RESOURCE `oracle_odbc`PROPERTIES ("type" = "odbc_catalog","host" = "192.168.0.1","port" = "8086","user" = "test","password" = "test","database" = "test","odbc_type" = "oracle","driver" = "Oracle 19 ODBC driver");CREATE EXTERNAL TABLE `baseall_oracle` (`k1` decimal(9, 3) NOT NULL COMMENT "",`k2` char(10) NOT NULL COMMENT "",`k3` datetime NOT NULL COMMENT "",`k5` varchar(20) NOT NULL COMMENT "",`k6` double NOT NULL COMMENT "") ENGINE=ODBCCOMMENT "ODBC"PROPERTIES ("odbc_catalog_resource" = "oracle_odbc","database" = "test","table" = "baseall");
参数 | 说明 |
hosts | 外表数据库的 IP 地址 |
driver | ODBC 外表的 Driver名,该名字需要和 be/conf/odbcinst.ini 中的 Driver 名一致。 |
odbc_type | 外表数据库的类型,当前支持 Oracle,Mysql,Postgresql |
user | 外表数据库的用户名 |
password | 对应用户的密码信息 |
charset | 数据库连接使用的字符集 |
PROPERTIES
中除了可以添加上述参数之外,还支持每个数据库的 ODBC Driver 实现的专用参数,例如 Mysql 的sslverify
等。[MySQL Driver]Description = ODBC for MySQLDriver = /usr/lib64/libmyodbc8w.soFileUsage = 1
[]
里的对应的是 Driver 名,在建立外部表时需要保持外部表的 Driver 名和配置文件之中的一致。Driver=
这个要根据实际 BE 安装 Driver 的路径来填写,本质上就是一个动态库的路径,这里需要保证该动态库的前置依赖都被满足。select * from oracle_table where k1 > 1000 and k3 ='term' or k4 like '%doris';
insert into oracle_table values(1, "doris");insert into oracle_table select * from postgre_table;
enable_odbc_transcation
设置。set enable_odbc_transcation = true;
Mysql 版本 | Mysql ODBC 版本 |
8.0.27 | 8.0.27, 8.026 |
5.7.36 | 5.3.11, 5.3.13 |
5.6.51 | 5.3.11, 5.3.13 |
5.5.62 | 5.3.11, 5.3.13 |
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
PostgreSQL 版本 | PostgreSQL ODBC 版本 |
12.9 | postgresql12-odbc-13.02.0000 |
13.5 | postgresql13-odbc-13.02.0000 |
14.1 | postgresql14-odbc-13.02.0000 |
9.6.24 | postgresql96-odbc-13.02.0000 |
10.6 | postgresql10-odbc-13.02.0000 |
11.6 | postgresql11-odbc-13.02.0000 |
Oracle 版本 | Oracle ODBC 版本 |
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production | oracle-instantclient19.13-odbc-19.13.0.0.0 |
Oracle Database 12c Standard Edition Release 12.2.0.1.0 - 64bit Production | oracle-instantclient19.13-odbc-19.13.0.0.0 |
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production | oracle-instantclient19.13-odbc-19.13.0.0.0 |
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production | oracle-instantclient19.13-odbc-19.13.0.0.0 |
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production | oracle-instantclient19.13-odbc-19.13.0.0.0 |
https://download.oracle.com/otn_software/linux/instantclient/1913000/oracle-instantclient19.13-sqlplus-19.13.0.0.0-2.x86_64.rpmhttps://download.oracle.com/otn_software/linux/instantclient/1913000/oracle-instantclient19.13-devel-19.13.0.0.0-2.x86_64.rpmhttps://download.oracle.com/otn_software/linux/instantclient/1913000/oracle-instantclient19.13-odbc-19.13.0.0.0-2.x86_64.rpmhttps://download.oracle.com/otn_software/linux/instantclient/1913000/oracle-instantclient19.13-basic-19.13.0.0.0-2.x86_64.rpm
Mysql 版本 | Mysql ODBC 版本 |
8.0.27 | 8.0.11, 5.3.13 |
PostgreSQL版本 | PostgreSQL ODBC版本 |
12.9 | psqlodbc-12.02.0000 |
sudo apt-get install alien
sudo alien -i oracle-instantclient19.13-basic-19.13.0.0.0-2.x86_64.rpmsudo alien -i oracle-instantclient19.13-devel-19.13.0.0.0-2.x86_64.rpmsudo alien -i oracle-instantclient19.13-odbc-19.13.0.0.0-2.x86_64.rpmsudo alien -i oracle-instantclient19.13-sqlplus-19.13.0.0.0-2.x86_64.rpm
MySQL | Doris | 替换方案 |
BOOLEAN | BOOLEAN | - |
CHAR | CHAR | 当前仅支持 UTF8编码 |
VARCHAR | VARCHAR | 当前仅支持 UTF8编码 |
DATE | DATE | - |
FLOAT | FLOAT | - |
TINYINT | TINYINT | - |
SMALLINT | SMALLINT | - |
INT | INT | - |
BIGINT | BIGINT | - |
DOUBLE | DOUBLE | - |
DATETIME | DATETIME | - |
DECIMAL | DECIMAL | - |
PostgreSQL | Doris | 替换方案 |
BOOLEAN | BOOLEAN | - |
CHAR | CHAR | 当前仅支持 UTF8编码 |
VARCHAR | VARCHAR | 当前仅支持 UTF8编码 |
DATE | DATE | - |
REAL | FLOAT | - |
SMALLINT | SMALLINT | - |
INT | INT | - |
BIGINT | BIGINT | - |
DOUBLE | DOUBLE | - |
TIMESTAMP | DATETIME | - |
DECIMAL | DECIMAL | - |
Oracle | Doris | 替换方案 |
不支持 | BOOLEAN | Oracle 可用 number(1) 替换 boolean |
CHAR | CHAR | - |
VARCHAR | VARCHAR | - |
DATE | DATE | - |
FLOAT | FLOAT | - |
无 | TINYINT | Oracle 可由 NUMMBER 替换 |
SMALLINT | SMALLINT | - |
INT | INT | - |
无 | BIGINT | Oracle 可由 NUMMBER 替换 |
无 | DOUBLE | Oracle 可由 NUMMBER 替换 |
DATETIME | DATETIME | - |
NUMBER | DECIMAL | - |
SQLServer | Doris | 替换方案 |
BOOLEAN | BOOLEAN | - |
CHAR | CHAR | 当前仅支持 UTF8编码 |
VARCHAR | VARCHAR | 当前仅支持 UTF8编码 |
DATE | DATE | - |
REAL | FLOAT | - |
TINYINT | TINYINT | - |
SMALLINT | SMALLINT | - |
INT | INT | - |
BIGINT | BIGINT | - |
FLOAT | DOUBLE | - |
DATETIME/DATETIME2 | DATETIME | - |
DECIMAL/NUMERIC | DECIMAL | - |
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
, 并重新启动所有 BE。driver connect Err: 01000 [unixODBC][Driver Manager]Can't open lib 'Xxx' : file not found (0)
。
没有在每一个BE上安装好对应数据的 Driver,或者是没有在 be/conf/odbcinst.ini 配置正确的路径,抑或是建表是 Driver 名与 be/conf/odbcinst.ini 不同。Fail to convert odbc value 'PALO ' TO INT on column:'A'
?
ODBC 外表的 A 列类型转换出错,说明外表的实际列与 ODBC 的映射列的数据类型不同,需要修改列的类型映射。explain
查询语句进行确认。driver connect Err: xxx
?
通常是连接数据库失败,Err 部分代表了不同的数据库连接失败的报错。这种情况通常是配置存在问题。可以检查是否错配了 IP 地址,端口或账号密码。charset
=utf8mb4
,便可以正常读写 emoji 表情。
本页内容是否解决了您的问题?