如何在特定模式中转储区分大小写的表

Ber*_*tuz 6 postgresql postgresql-9.2 pg-dump

我正在尝试app_auth.User通过执行以下命令转储一个区分大小写的表

pg_dump --schema=app_auth -t '"User"' -U em3local -h 127.0.0.1 -Fc -a -f <path> <dbname>
Run Code Online (Sandbox Code Playgroud)

但我返回的是:

pg_dump: No matching tables were found
Run Code Online (Sandbox Code Playgroud)

如果我实际查询我的数据库,该表确实存在:

<dbname>=# SELECT * FROM app_auth."User";
 username | email | password | name | surname | lang | resettoken | userinfo_id | state | tos_accepted | id 
----------+-------+----------+------+---------+------+------------+-------------+-------+--------------+----
Run Code Online (Sandbox Code Playgroud)

任何提示?

Abe*_*sto 7

当您指定要卸载的架构名称时,并不意味着它将是搜索对象的默认架构:

nd@postgres=# create schema foobar;
CREATE SCHEMA
nd@postgres=# create table foobar."Foo"();
CREATE TABLE
nd@postgres=# \! pg_dump --schema=foobar -t "Foo"
pg_dump: no matching tables were found
Run Code Online (Sandbox Code Playgroud)

所以你应该完全限定表名:

nd@postgres=# \! pg_dump --schema=foobar -t 'foobar."Foo"'
--
-- PostgreSQL database dump
--
... etc ...
Run Code Online (Sandbox Code Playgroud)

文档摘录(草书和粗体是我的):

-n 和 -N (--schema)开关在使用 -t 时不起作用,因为 -t 选择的表将被转储而不管这些开关如何,并且不会转储非表对象。

以前,写入 -t tab 会转储所有名为 tab 的表,但现在它只会转储默认搜索路径中可见的任何一个