5

I'm beginner with PostgreSQL and doing backups using:

sudo -u postgres pg_dumpall > /~/postgreBackup.SQL

Works fine! Now I want to backup a single table "TableName" in a scheme "SchemeName" and tried

sudo -u postgres pg_dump --table "SchemaName"."TableName" > /~/Dummy.SQL

pg_dump: no matching tables were found

How to get it working?

asked Jul 21, 2020 at 18:13
4
  • What are the actual table names (please quote verbatim from the successful dump), and what is the exact --table parameter that you used in the second command? Commented Jul 21, 2020 at 19:45
  • You don't specifiy the database in your command. Also, check your schema and table names with psql -U postgres -d $Your_Database -c '\d'. Commented Jul 21, 2020 at 19:51
  • Sorry, I'm totally lost: The Database is "myDatabase", it has the scheme "public" and two schemes for working "myScheme" and "SandBox". Within "MyScheme" I have the table "TableName 01" tht is desired to be dumped. Commented Jul 22, 2020 at 7:57
  • psql -U postgres -d $"myDatabase" -c '\d' results in List of relations for scheme public ... Commented Jul 22, 2020 at 8:04

1 Answer 1

11

When you have case sensitive table and schema name you have to do the proper quoting of a table name. The below command should work fine as I have successfully executed it at my end.

Please make sure you are using the correct case sensitive name of database, schema and table in this command.

./pg_dump --dbname="myDatabase" --host=localhost --port=5432 --username=postgres --table='"MyScheme"."TableName 01"' --file=Dummy

OR

./pg_dump --dbname="myDatabase" --host=localhost --port=5432 --username=postgres --table='"MyScheme"."TableName 01"' > ~/Dummy.SQL
Martijn Pieters
1.1m326 gold badges4.2k silver badges3.5k bronze badges
answered Jul 23, 2020 at 8:57
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.