如何在 PostgreSQL 中进行仅模式备份和还原? [英] How do I do a schema only backup and restore in PostgreSQL?

查看:61
本文介绍了如何在 PostgreSQL 中进行仅模式备份和还原?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 PostgreSQL 数据库中进行模式级备份并在另一个数据库上恢复?是否有任何可用的命令?比如我可以单行pg_dump和restore吗?

How do I take a schema level backup in PostgreSQL database and restore on the another database? Is there any single command available for this? For example, can I pg_dump and restore in single line?

推荐答案

pg_dump --schema=masters oldDB > masters1.sql
cat masters1.sql | psql newDB

在单个命令中你可以这样做

in single command you can do by this

pg_dump oldDB --schema masters  | psql -h localhost newDB;

这篇关于如何在 PostgreSQL 中进行仅模式备份和还原?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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