postgresql 用于导入/导出数据/ddl 的 Postgres 命令行工具

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2314012/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-20 00:02:53  来源:igfitidea点击:

Postgres Command Line tool for Import/Exporting data/ddl

sqldatabasepostgresqlddl

提问by mainstringargs

For Postgres is there any sort of command line utilities that allow a database to be "dumped to a file" and that allow that same database dump to be imported?

对于 Postgres,是否有任何类型的命令行实用程序允许将数据库“转储到文件”并允许导入相同的数据库转储?

I know this can be done through PGAdmin, but I need to be able to do this on the cmd line.

我知道这可以通过 PGAdmin 来完成,但我需要能够在 cmd 行上做到这一点。

回答by Joshua D. Drake

Correct, the way to do this is the pg_dump, pg_dumpall and pg_restore commands. In fact, I think pg_admin actually calls those commands itself. It doesn't actually have backup/restore built in but is just a wrapper.

正确,这样做的方法是 pg_dump、pg_dumpall 和 pg_restore 命令。事实上,我认为 pg_admin 实际上调用了这些命令本身。它实际上并没有内置备份/恢复功能,而只是一个包装器。