[英]Is there a way to create a linked server from an Azure SQL database to PostgreSQL?
I have been doing some research and I am yet to see a solution regarding this question.我一直在做一些研究,但我还没有看到关于这个问题的解决方案。 Does anyone know if it's actually possible to create a linked server from an Azure SQL database in order to connect it to a PostgreSQL database?有谁知道是否真的可以从 Azure SQL 数据库创建链接服务器以将其连接到 PostgreSQL 数据库?
I noticed the folder server objects
is present in the local database, however, on Azure that folder is non-existent.我注意到本地数据库中存在文件夹server objects
,但是,在 Azure 上该文件夹不存在。 Am I right to assume linked server is not supported on the Azure SQL database?我认为 Azure SQL 数据库不支持链接服务器是否正确?
Yes, you're right.你是对的。
Azure SQL database(single database) doesn't support linked server . Azure SQL 数据库(单数据库)不支持链接服务器。 We can not create the linked server to any other Server.我们不能创建链接服务器到任何其他服务器。
I found an another way may can help you connect to Postgresql.我发现另一种方法可以帮助您连接到 Postgresql。
Please reference this tutorial: Connect to PostgreSQL as an External Data Source using PolyBase :请参考本教程:使用 PolyBase 连接到 PostgreSQL 作为外部数据源:
Use the CData ODBC Driver for PostgreSQL and PolyBase to create an external data source in SQL Server 2019 with access to live PostgreSQL data.使用适用于 PostgreSQL 和 PolyBase 的 CData ODBC 驱动程序在 SQL Server 2019 中创建外部数据源,以访问实时 PostgreSQL 数据。
Creating a Master Encryption Key创建主加密密钥
Execute the following SQL command to create a new master key, 'ENCRYPTION,' to encrypt the credentials for the external data source.执行以下 SQL 命令以创建新的主密钥“ENCRYPTION”,以加密外部数据源的凭据。
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'password';
Creating a Credential Database创建凭证数据库
Execute the following SQL command to create credentials for the external data source connected to PostgreSQL data.执行以下 SQL 命令为连接到 PostgreSQL 数据的外部数据源创建凭据。
CREATE DATABASE SCOPED CREDENTIAL postgresql_creds
WITH IDENTITY = 'username', SECRET = 'password';
Create an External Data Source for PostgreSQL为 PostgreSQL 创建外部数据源
Execute the following SQL command to create an external data source for PostgreSQL with PolyBase, using the DSN and credentials configured earlier.执行以下 SQL 命令,使用之前配置的 DSN 和凭据为 PostgreSQL 和 PolyBase 创建外部数据源。
CREATE EXTERNAL DATA SOURCE cdata_postgresql_source
WITH (
LOCATION = 'odbc://SERVERNAME[:PORT]',
CONNECTION_OPTIONS = 'DSN=CData PostgreSQL Sys',
-- PUSHDOWN = ON | OFF,
CREDENTIAL = postgresql_creds
);
Create External Tables for PostgreSQL为 PostgreSQL 创建外部表
The statement to create an external table based on a PostgreSQL Orders would look similar to the following:基于 PostgreSQL 订单创建外部表的语句类似于以下内容:
CREATE EXTERNAL TABLE Orders(
ShipName [nvarchar](255) NULL,
ShipCity [nvarchar](255) NULL,
...
) WITH (
LOCATION='Orders',
DATA_SOURCE=cdata_postgresql_source
);
I couldn't test this for you because I don't have PostgreSQL.我无法为您测试这个,因为我没有 PostgreSQL。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.