在 Postgres 中将表从一个数据库复制到另一个数据库 [英] Copy a table from one database to another in Postgres
本文介绍了在 Postgres 中将表从一个数据库复制到另一个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在 Postgres 中将整个表从一个数据库复制到另一个数据库.有什么建议吗?
I am trying to copy an entire table from one database to another in Postgres. Any suggestions?
推荐答案
提取表并通过管道将其直接传送到目标数据库:
Extract the table and pipe it directly to the target database:
pg_dump -t table_to_copy source_db | psql target_db
注意:如果其他数据库已经设置了表,你应该使用 -a
标志只导入数据,否则你可能会看到像内存不足":
Note: If the other database already has the table set up, you should use the -a
flag to import data only, else you may see weird errors like "Out of memory":
pg_dump -a -t my_table my_db | psql target_db
这篇关于在 Postgres 中将表从一个数据库复制到另一个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文