【问题标题】:Dot (.) in Schema name makes pg_dump unusableSchema 名称中的点 (.) 使 pg_dump 无法使用
【发布时间】:2014-01-14 02:01:03
【问题描述】:

我有一个名为 2sample.sc 的架构。当我想pg_dump它的一些表时,出现如下错误:

pg_dump: No matching tables were found

我的 pg_dump 命令:

pg_dump -U postgres -t 2sample.sc."error_log" --inserts games > dump.sql

我的 pg_dump 在 2sample 等其他模式上运行良好。

我做了什么:

  • 我尝试转义 dot(.) 但没有成功

【问题讨论】:

    标签: postgresql schema pg-dump


    【解决方案1】:

    使用"schema.name.with.dots.in.it"."table.name.with.dots.in.it" 指定schema.table:

            -- test schema with a dot in its name
    DROP SCHEMA "tmp.tmp" CASCADE;
    CREATE SCHEMA "tmp.tmp" ;
    SET search_path="tmp.tmp";
    
    CREATE TABLE nononono
            ( dont SERIAL NOT NULL
            );
    
    insert into nononono
    SELECT generate_series(1,10)
            ;
    

    $pg_dump -t \"tmp.tmp\".\"nononono\" --schema-only -U postgres the_database
    

    输出(截断):

    SET search_path = "tmp.tmp", pg_catalog;
    SET default_tablespace = '';
    SET default_with_oids = false;
    
    --
    -- Name: nononono; Type: TABLE; Schema: tmp.tmp; Owner: postgres; Tablespace:
    --
    
    CREATE TABLE nononono (
        dont integer NOT NULL
    );
    

    顺便说一句:为什么要在架构(或表)名称中添加一个点?这是自找麻烦。 MixedCaseNames 也是如此。下划线很好用。

    【讨论】:

    • 手册中的所有内容--schema "the_name"(或-n "the_name")应该可以工作。 shell 可能会吃掉",因此您必须通过添加反斜杠来转义引号。
    • 我正在处理一个现有项目。如果我是他们,我肯定会使用 _ 或其他东西。
    • 恕我直言,你(他们)应该尽快重构它。这只是一天左右的工作。这种努力将在一年左右的时间内得到回报。这是一场等待发生的灾难。
    • 我们会尽快处理。感谢您的推荐。
    猜你喜欢
    • 2012-10-27
    • 2021-08-21
    • 2019-01-21
    • 2019-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多