我想使用其他架构还原数据库 [英] I want to restore the database with a different schema

查看:56
本文介绍了我想使用其他架构还原数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下命令对名为 temp1 的数据库进行了转储

I have taken a dump of a database named temp1, by using the follwing command

$  pg_dump -i -h localhost  -U postgres -F c -b -v -f pub.backup temp1 

现在,我想将转储恢复到另一个名为 db_temp的数据库中,但是我只想所有表都应在 temp_schema中创建(而不是默认模式,即 db_temp数据库​​中的fms temp1数据库)。

Now I want to restore the dump in a different database called "db_temp" , but in that I just want that all the tables should be created in a "temp_schema" ( not the default schema which is in the fms temp1 database ) which is in the "db_temp" database.

有什么方法可以使用 pg_restore 命令吗?

Is there any way to do this using pg_restore command?

还可以使用其他方法!

推荐答案

pg_restore本身是没有办法的。您可以使用pg_restore生成SQL输出,然后通过例如sed脚本将其发送以进行更改。不过,您需要注意如何编写该sed脚本,以使其与数据中的内容不匹配并且无法更改。

There's no way in pg_restore itself. What you can do is use pg_restore to generate SQL output, and then send this through for example a sed script to change it. You need to be careful about how you write that sed script though, so it doesn't match and change things inside your data.

这篇关于我想使用其他架构还原数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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