12

I'm trying to dump a case-sensitive table named app_auth.User by executing the following command

pg_dump --schema=app_auth -t '"User"' -U em3local -h 127.0.0.1 -Fc -a -f <path> <dbname>

but what I'm returned is:

pg_dump: No matching tables were found

If I actually query my DB, the table does exist:

<dbname>=# SELECT * FROM app_auth."User";
 username | email | password | name | surname | lang | resettoken | userinfo_id | state | tos_accepted | id 
----------+-------+----------+------+---------+------+------------+-------------+-------+--------------+----

any hint?

Bertuz
  • 255
  • 2
  • 7

1 Answers1

10

When you specifies the schema name to unload it does not mean that it will be default schema to search objects:

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

So you should to fully qualify the table name:

nd@postgres=# \! pg_dump --schema=foobar -t 'foobar."Foo"'
--
-- PostgreSQL database dump
--
... etc ...

Excerpt from the documentation (cursive and bold is mine):

The -n and -N (--schema) switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped.

Formerly, writing -t tab would dump all tables named tab, but now it just dumps whichever one is visible in your default search path.

Abelisto
  • 1,589
  • 1
  • 10
  • 14