且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Postgres 中将表从一个数据库复制到另一个数据库

更新时间:2023-02-03 22:58:19

提取表并通过管道将其直接传送到目标数据库:

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