【问题标题】:how to create dump for specific schema in postgres DB如何在 postgres DB 中为特定模式创建转储
【发布时间】:2019-04-29 14:10:50
【问题描述】:

我有一个 Postgres 数据库“rafiu”,其中包含许多模式,即 test1、test2、test3。在此我想转储 test2 模式及其数据。我尝试了以下查询

pg_dump -U postgres -n test2 -t t1 -t t2 rafiu > test_schema.sql

但它在结果转储文件中转储了 public.t1、public.t2 表而不是 test2 模式表。

请建议我如何在数据库中创建特定于转储的模式。

提前致谢。

【问题讨论】:

    标签: postgresql pg-dump


    【解决方案1】:

    -n test2 表示转储架构test2

    如果你想转储表test2.t1test2.t2,你可能想试试下面的语句:

    pg_dump -U postgres -t test2.t1 -t test2.t2 rafiu > test_schema.sql
    

    【讨论】:

    • 来自一个模式的全部数据怎么样?使用他的示例,从test2获取所有表?
    猜你喜欢
    • 2012-08-10
    • 2019-03-23
    • 1970-01-01
    • 2015-01-04
    • 2014-03-25
    • 2015-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多