简体   繁体   English

将 SQL 服务器数据库连接到 PostgreSQL

[英]Connect SQL Server database to PostgreSQL

I want to connect a SQL Server database by using pgAdmin4 .我想使用pgAdmin4连接 SQL 服务器数据库。 I already have data in the SQL Server database and want to connect this database in PostgreSQL.我已经在 SQL 服务器数据库中有数据,并且想在 PostgreSQL 中连接这个数据库。 I have tried with foreign data also but not working.我也尝试过使用外国数据,但没有工作。

If anyone knows the solution it would be really appreciated.如果有人知道解决方案,将不胜感激。

There are two solutions that I've used:我使用过两种解决方案:

Solution 1: tds_fdw解决方案1: tds_fdw

You can install tds_fdw that is a foreign data wrapper to MSSQL to postgreSQL and, with this foreign data wrapper, you can use your MSSQL tables and schemas as foreign tables inside postgresql.您可以将tds_fdw作为 MSSQL 的外部数据包装器安装到 postgreSQL,并且使用此外部数据包装器,您可以将 MSSQL 表和模式用作 postgresql 中的外部表。 More details here .更多细节在这里

As you not provisioned which OS you are using, is better to se inside the project and apply as your needs.由于您没有配置您正在使用的操作系统,因此最好在项目中设置并根据您的需要应用。

Solution 2: Apache Kafka and Debezium解决方案2: Apache Kafka 和 Debezium

A little bit complicated than installing a fdw , you can do a streaming replication enabling CDC on MSSQL Server and collecting via Debezium the tables that you need and real-time replicating to you PostgreSQL database connecting via JDBC so, you need what is your scenario and decide what is the best option.比安装fdw有点复杂,您可以在 MSSQL Server 上启用 CDC 并通过 Debezium 收集您需要的表并实时复制到您 PostgreSQL 数据库通过 JDBC 连接的数据库,所以,您需要什么是您的场景和决定什么是最好的选择。

tds_fdw is good, but maybe you should find the windows install package. tds_fdw很好,但也许你应该找到 windows 安装 package。

Otherwise, if you just want to use one tool that you can query data from both Databases, you should try dbeaver or navicat .否则,如果您只想使用一种工具来查询两个数据库中的数据,您应该尝试dbeavernavicat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM