将表数据从一个数据库复制到另一个数据库 [英] Copy Table data from one DB to another

查看:134
本文介绍了将表数据从一个数据库复制到另一个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于开发,我发现自己需要经常将表信息从一个表复制到另一个表.我很好奇,对于Postgres而言,最简单的解决方案是什么?我有PGAdminIII,但看起来它确实只支持冗长的备份/还原.

For development I find myself needing to copy table information from one table to another quite often. I am just curious what are the easiest solutions to do this for Postgres. I have PGAdminIII but it looks like it really only support the long drawn out Backup/Restore.

在某处是否有python或bash脚本,或者我可以给它提供基本信息的东西?

Is there a python or bash script somewhere or something that I can just give it the basic infomation?

  • 这里是DB1
  • 这里是DB2
  • 复制表格...
  • 开始!

我相信SQLYog在Win32中为MySQL做到了这一点,但是我现在在OSX上并使用Postgres.

I believe SQLYog did this for MySQL in Win32, but I am now on OSX and using Postgres.

推荐答案

如果仅在两个PostgreSQL数据库之间移动,一个好方法是仅在管道(或pg_dump和psql)中使用pg_dump和pg_restore.基本上

If you're just moving between two PostgreSQL databases, a good way is to just use pg_dump and pg_restore in a pipe (or pg_dump and psql). Basically

pg_dump -Fc db1 | pg_restore -d db2 -c

(根据您的环境调整开关,请参见手册页)

(adjust switches as necessary for your environment, see the man pages)

这是您已经安装的工具,如果您只想传输数据而不修改它,它会比Kettle等成熟的ETL快很多.

It's tools you have already installed, and if you just want to transfer the data and not modify it, it'll be a lot faster than a full-blown ETL too like Kettle.

这篇关于将表数据从一个数据库复制到另一个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆