测试操作系统:Centos 7.6 测试IP :192.168.112.88 操作系统安装信息:最小化安装 官方网站: https://github.com/laurenz/oracle_fdw http://laurenz.github.io/oracle_fdw/ Requirements: PostgreSQL 9.3 or better Oracle client 11.2 or better For EXPLAIN VERBOSE, SELECT privileges on V$SQL and V$SQL_PLAN You need to install Oracle's C header files as well (SDK package for Instant Client). If you use the Instant Client ZIP files provided by Oracle, you will have to create a symbolic link from libclntsh.so to the actual shared library file yourself. 1.准备oracle环境 根据Requirements, fdw 明确要求需要 instanct client 以及 sdk package. instantclient-sdk-linux.x64-11.2.0.4.0.zip instantclient-basic-linux.x64-11.2.0.4.0.zip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip (可选) [root@PGHOST u01]# unzip instantclient-basic-linux.x64-11.2.0.4.0.zip [root@PGHOST u01]# unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip [root@PGHOST u01]# unzip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip 文件均解压到目录 /u01/instantclient_11_2 PATH=$PATH:$HOME/bin:/pgsoft/bin:/u01/pgbadger-11.3:/u01/instantclient_11_2 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/pgsoft/lib:/u01/instantclient_11_2 export PATH 2.上传安装 fdw [root@PGHOST u01]# unzip oracle_fdw-master.zip [root@PGHOST u01]# cd oracle_fdw-master [root@PGHOST oracle_fdw-master]# make [root@PGHOST oracle_fdw-master]# make install 3.验证fdw [root@PGHOST oracle_fdw-master]# ldd oracle_fdw.so linux-vdso.so.1 => (0x00007fff084ef000) libclntsh.so.11.1 => /u01/instantclient_11_2/libclntsh.so.11.1 (0x00007f812b6c9000) libc.so.6 => /lib64/libc.so.6 (0x00007f812b2fc000) libnnz11.so => /u01/instantclient_11_2/libnnz11.so (0x00007f812af2f000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f812ad2b000) libm.so.6 => /lib64/libm.so.6 (0x00007f812aa29000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f812a80d000) libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f812a5f3000) libaio.so.1 => /lib64/libaio.so.1 (0x00007f812a3f1000) /lib64/ld-linux-x86-64.so.2 (0x00007f812e25c000) 4.配置oracle_fdw 4.1 基本配置 Then configure oracle_fdw as PostgreSQL superuser like this: pgdb=# CREATE EXTENSION oracle_fdw; pgdb=# CREATE SERVER oradb FOREIGN DATA WRAPPER oracle_fdw OPTIONS (dbserver '//192.168.112.77:1521/testdb'); pgdb=# GRANT USAGE ON FOREIGN SERVER oradb TO pguser; Then you can connect to PostgreSQL as pguser and define: pgdb=> CREATE USER MAPPING FOR pguser SERVER oradb OPTIONS (user 'system', password 'oracle'); 4.2 手动创建外部表 pgdb=> CREATE FOREIGN TABLE TEST ( id int, text character varying(30) ) SERVER oradb OPTIONS (schema 'SYSTEM', table 'TEST'); postgres=# select * from TEST; id | text -----+------ 100 | sss (1 row) 4.3 使用import FOREIGN SCHEMA 一键创建外部表 postgres=# drop user mapping for postgres server oradb; postgres=# CREATE USER MAPPING FOR postgres SERVER oradb OPTIONS (user 'myuser', password 'oracle'); postgres=# create schema r1; postgres=# import FOREIGN SCHEMA "MYUSER" from server oradb into r1 ; postgres=# select * from r1.test; id | text -----+------ 300 | sss (1 row)
oracle_fdw
来源:这里教程网
时间:2026-03-14 19:53:09
作者:
编辑推荐:
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 美创科技运维日记|postgresql-pg简易异步流复制搭建
美创科技运维日记|postgresql-pg简易异步流复制搭建
26-03-14 - 如何利用PostgreSQL实现海量数据无限空间存储
如何利用PostgreSQL实现海量数据无限空间存储
26-03-14 - Excel快速选择一列的高效快捷方法实例教程
Excel快速选择一列的高效快捷方法实例教程
26-03-14 - PostgreSQL.Live生而全球 敢于颠覆
PostgreSQL.Live生而全球 敢于颠覆
26-03-14 - PostgreSQL 10.1中文手册 PDF版 完整版高清下载
PostgreSQL 10.1中文手册 PDF版 完整版高清下载
26-03-14 - 企业级云数据库最佳实践
企业级云数据库最佳实践
26-03-14 - 直播就在今晚!PostgreSQL专题 【恩墨面对面】
直播就在今晚!PostgreSQL专题 【恩墨面对面】
26-03-14 - PostgreSQL:Redhat 7.8 上安装
PostgreSQL:Redhat 7.8 上安装
26-03-14 - Wxcel 表格数据有增加 图表自适应
Wxcel 表格数据有增加 图表自适应
26-03-14 - Greenplum 学习实践-总体思维导图
Greenplum 学习实践-总体思维导图
26-03-14
