pg_restore会覆盖现有表吗? [英] will pg_restore overwrite the existing tables?

查看:623
本文介绍了pg_restore会覆盖现有表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有两个主机服务器s1和s2。在两个服务器中,我都有一个名为n1的架构,现在我对s1的架构n1中存在的某些表进行了一些更改。我希望对服务器s2的架构n1进行相同的更改。我打算做的是使用pg_dump备份服务器s1的架构n1,并使用pg_restore还原到服务器s2。现在我的问题是,因为服务器s2中已经存在具有相同表集的相同架构n1。恢复过程将做什么?它会覆盖现有表吗?还是应该删除服务器s2的现有架构,并使用服务器s1的转储将其还原?

Say I have two host servers s1 and s2. In both the servers i have a schema named n1, now i have made some changes to some of the tables present in schema n1 of s1. I want the same change to be done to schema n1 of server s2. what i am planning to do is to take a backup of the schema n1 of server s1 using pg_dump and restore in the server s2 using pg_restore. Now my question is ,since there is already the same schema n1 in the server s2 with the same set of tables. what the restore process will do? will it overwrite the existing tables or should i drop the existing schema of server s2 and restore it using the dump from server s1?

推荐答案

如果使用<$ c的-clean 选项$ c> pg_restore ,旧表将在创建新表之前被删除。

If you use the --clean option of pg_restore, the old tables will be dropped before the new ones are created.

如果不使用-clean 选项,您将收到一条错误消息,表明该表已存在,但是 pg_restore 将继续处理,除非您使用-错误退出选项。

If you do not use the --clean option, you will get an error message that the table already exists, but pg_restore will continue processing unless you use the --exit-on-error option.

这篇关于pg_restore会覆盖现有表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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