简体   繁体   English

有没有办法创建从 Azure SQL 数据库到 PostgreSQL 的链接服务器?

[英]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.

相关问题 如何在SQL Server 2017中使用MFA创建Azure SQL数据库的链接服务器 - How to create a Linked Server of Azure SQL Database with MFA in SQL Server 2017 使用域服务帐户在本地 SQL 服务器到 Azure SQL 数据库中创建链接服务器 - Create a Linked Server in On-Prem SQL Server to Azure SQL Database using Domain Service Account 将大型表从sql server复制到ssms中的odbc链接数据库(postgresql) - copy large table from sql server to odbc linked database (postgresql) in ssms 如何将文本数据类型从PostgreSQL数据库转换/广播到链接的MS SQL Server? - How can you convert/cast text datatypes from a PostgreSQL database to a linked MS SQL Server? 有没有办法从SQL Server数据库创建自动创建属性? - Is there a way to create automatically create properties from a SQL Server database? 设置从SQL Server 2005到PostgreSQL的链接服务器 - Setting up a linked server from SQL Server 2005 to PostgreSQL 从 SQL Express 实例创建到 SQL Azure 数据库的链接服务器时出错“此版本的 SQL Server 不支持 Windows 登录。” - Error in creating a linked server to SQL Azure database from a SQL Express instance “Windows logins are not supported in this version of SQL Server.” SQL-Server在没有链接服务器的远程服务器上创建数据库 - SQL-Server Create database on remote server without linked server 从链接的MS SQL Server复制数据库 - Copy database from linked MS SQL server 来自Premise SQL Server上的Azure链接的SQL Server-MSDTC异常 - Azure Linked SQL server from on Premise SQL Server - MSDTC exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM