postgresql 如何创建 postgres 数据库架构的 sql 脚本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7804698/
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-10 23:08:42  来源:igfitidea点击:

How to create sql script of postgres database schema?

postgresql

提问by DMS

I want sql script of postgres 9 database schema which is not on local server. I tried pg_dump command on sql editor of pgAdmin and its not working there. I m not sure where to run that command. Please assist me with the same.... Thanks..

我想要不在本地服务器上的 postgres 9 数据库模式的 sql 脚本。我在 pgAdmin 的 sql 编辑器上尝试了 pg_dump 命令,但它在那里不起作用。我不确定在哪里运行该命令。请帮助我同样....谢谢..

回答by Bohemian

pg_dumpis a command line utility; it isn't SQL, so it won't work in pgAdmin or anywhere else that executes SQL.

pg_dump是一个命令行实用程序;它不是 SQL,所以它不能在 pgAdmin 或其他任何执行 SQL 的地方工作。

pgAdminhowever does have a facility to do what you want:

pgAdmin但是确实有能力做你想做的事:

  1. Right-click on the database you want to export
  2. Select Backupfrom the pop-up menu
  3. Chose "format" Plain
  4. Chose "plain option" Only schema
  1. 右键单击要导出的数据库
  2. 选择Backup从弹出菜单
  3. 选择“格式” Plain
  4. 选择“普通选项” Only schema

回答by Anvesh

You can also use pgAdmin tool to generate or take plain text Database Backup. You can generate plain text backup for data or schema only.

您还可以使用 pgAdmin 工具生成或进行纯文本数据库备份。您只能为数据或模式生成纯文本备份。

I have shared few screen shots, please visit this blogfor more details.

我分享了一些屏幕截图,请访问此博客了解更多详细信息。