Postgresql连接查询 MS SQL Server
简介
PostgreSQL从9.x开始支持所谓的外表的功能,就是在PostgreSQL中通过安装一些扩展再进行一些配置可以在本地建立一个外表映射到其他不同类型的数据库。
今天我们介绍一下在PostgreSQL中通过tds_fdw扩展来映射Sqlserver数据库的方法
环境
- Sqlserver:
操作系统:Windows 8
数据库系统: MS SQL Server 2012
IP: 192.168.3.215
port: 1433
- PostgreSQL:
操作系统:CentOS Linux release 7.3.1611 (Core)
数据库系统: PostgreSQL 9.5.8
IP: 192.168.230.134
port: 5432
PostgreSQL端插件安装
- 安装EPEL repository
sudo yum install epel-release
输出:
[root@localhost ~]# sudo yum install epel-release
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
pgdg95 | 4.1 kB 00:00:00
updates | 3.4 kB 00:00:00
pgdg95/7/x86_64/primary_db | 163 kB 00:00:02
Loading mirror speeds from cached hostfile
* base: mirrors.sohu.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-9 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
epel-release noarch 7-9 extras 14 k
Transaction Summary
========================================================================================
Install 1 Package
Total download size: 14 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-9.noarch.rpm | 14 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-9.noarch 1/1
Verifying : epel-release-7-9.noarch 1/1
Installed:
epel-release.noarch 0:7-9
Complete!
- 安装FreeTDS
sudo yum install freetds freetds-devel
输出:
[root@localhost ~]# sudo yum install freetds freetds-devel
Loaded plugins: fastestmirror, langpacks
epel/x86_64/metalink | 6.5 kB 00:00:00
epel | 4.3 kB 00:00:00
(1/3): epel/x86_64/group_gz | 170 kB 00:00:00
(2/3): epel/x86_64/updateinfo | 817 kB 00:00:01
(3/3): epel/x86_64/primary_db | 4.8 MB 00:00:01
Loading mirror speeds from cached hostfile
* base: mirrors.sohu.com
* epel: mirrors.ustc.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package fre