简体   繁体   English

将现有表数据导入不同数据库中的新表(postgres)

[英]Importing existing table data to a new table in different database (postgres)

我想将一个数据库的现有表的所有数据导入到 postgres 中不同数据库中存在的新表中,任何建议都会有所帮助。

The easiest way would be to pg_dump the table and pg_restore in the target database.最简单的方法是在目标数据库中pg_dump表和pg_restore

In case it is not an option, you should definitely take a look a postgres_fdw (Foreign Data Wrapper), which allows you to access data from different databases - even from different machines.如果它不是一个选项,你绝对应该看看postgres_fdw (Foreign Data Wrapper),它允许你访问来自不同数据库的数据——甚至来自不同的机器。 It is slightly more complex than the traditional export/import approach, but it creates a direct connection to the foreign table.它比传统的导出/导入方法稍微复杂一些,但它创建了到外部表的直接连接。

Take a look at this example .看看这个example

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

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