Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

postgresql - PostgreSQL外部数据包装器(Postgresql foreign data wrapper)

hoping for some help as I am very new to postgresql admin!

(希望能获得一些帮助,因为我是Postgresql管理员的新手!)

I have 2 servers added to pgadmin, server 1 is a hosted db on Heroku the other is local to the server

(我将2个服务器添加到pgadmin中,服务器1是Heroku上的托管数据库,其他服务器本地)

I want to add the Heroku db as foreign tables to the local db

(我想将Heroku数据库作为外部表添加到本地数据库)

can I link these 2 servers?

(我可以链接这两个服务器吗?)

as so far I have failed

(到目前为止,我失败了)

I have the fdw extension setup locally, and I am able to use it across three local dbs ok, do I need the extension also setup on the Heroku db?

(我在本地设置了fdw扩展名,并且可以在三个本地数据库中使用它,确定,我是否还需要在Heroku db上设置该扩展名?)

I have setup the fdw server as host localhost --- should this be the Heroku host path?

(我已经将fdw服务器设置为主机localhost ---这应该是Heroku主机路径吗?)

or is this ok since I have added - --server local?

(还是可以,因为我添加了---server local?)

I get fsrvoption error if I add actual host path dbname dbname port 5432

(如果添加实际的主机路径dbname dbname端口5432,则会出现fsrvoption错误)

and then setup user user username password password

(然后设置用户用户名用户名密码密码)

any help appreciated!

(任何帮助表示赞赏!)

mal

(恶意的)

添加外部存储上主机的路径时出错

  ask by user7679705 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You don't have to set up anything on the remote server to access it via foreign data wrapper;

(您无需在远程服务器上进行任何设置即可通过外部数据包装器进行访问;)

the foreign data wrapper will access the remote database as a regular database client.

(外部数据包装器将作为常规数据库客户端访问远程数据库。)

Once you hace set up postgres_fdw correctly, you can use it to access tables on the remote server just as if they were local tables.

(一旦正确设置了postgres_fdw,就可以使用它来访问远程服务器上的表,就像它们是本地表一样。)

A foreign table is a bit like a view in some respects.

(在某些方面,外表有点像视图。)

Maybe it helps to understand the objects involved:

(也许有助于理解所涉及的对象:)

  • The foreign data wrapper encapsulates the code to access the remote data source (PostgreSQL client).

    (外部数据包装器封装了用于访问远程数据源(PostgreSQL客户端)的代码。)

  • The foreign server wraps the connect string for the remote database.

    (外部服务器包装远程数据库的连接字符串。)

  • The user mapping contains the credentials for a user to access the foreign server.

    (用户映射包含用户访问外部服务器的凭据。)

  • The foreign table describes a table on the remote server.

    (外部表描述了远程服务器上的表。)

You can use the command IMPORT FOREIGN SCHEMA to automatically define foreign tables for all (or part) of the tables in a schema on the remote server.

(您可以使用命令IMPORT FOREIGN SCHEMA自动为远程服务器上的架构中的所有(或部分)表定义外部表。)

Once the foreign tables are defined correctly, you can use them in SQL statements just like local tables, but you will actually read and write data on the remote server.

(一旦正确定义了外部表,就可以像本地表一样在SQL语句中使用它们,但是实际上您将在远程服务器上读写数据。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...