PostgreSQL数据库设计备份-无数据 [英] Backup of PostgreSQL database design - without data

查看:190
本文介绍了PostgreSQL数据库设计备份-无数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法来备份数据库设计而不包含数据库中存储的数据。实际上,也许有人会说我想拥有一个在数据库中包含所有创建脚本的文件。理想情况下,该文件可用于重新创建数据库(当然没有数据)。

I have tried to find a way to backup my database design without including the data stored in the database. Actually, one might say that I want to have a file that holds all "CREATE Scripts" in the database. Ideally, this file could be used to recreate the database (with no data of course).

如何避免数据库备份中的数据?

How to avoid data in a database backup?

我正在使用pgAdmin 4.1.3和PostgreSQL 9.6。

I am using pgAdmin 4.1.3 and PostgreSQL 9.6.

推荐答案

您可以在psql中使用它(终端):

You can use this from psql(terminal):

pg_dump -s databasename > file.dump

-s仅转储对象定义(模式),而不是数据。

from pg_dump documentation the "-s" dump only the object definitions (schema), not data.

pg_dump文档

这篇关于PostgreSQL数据库设计备份-无数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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