更新时间:2023-02-02 17:42:01
这是一个非常简单的任务.只需为此目的使用 dblink:
This is a really straightforward task. Just use dblink for this purpose:
INSERT INTO t(a, b, c)
SELECT a, b, c FROM dblink('host=xxx user=xxx password=xxx dbname=xxx', 'SELECT a, b, c FROM t') AS x(a integer, b integer, c integer)
如果您需要定期从外部数据库获取数据,***定义一个服务器和用户映射.然后,您可以使用更短的语句:
If you need to fetch data from external database on a regular basis, it would be wise to define a server and user mapping. Then, you could use shorter statement:
dblink('yourdbname', 'your query')