Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres dump specific table with a capital letter

I am trying to perform a postgres dump of a specific table using -t. However, the table has a capital letter in it and I get a "No matching tables were found." I tried using quotations and double quotations around the table name but they did not work. How can I get pg to recognize the capitals? Thanks!

pg_dump -h hostname dbname -t tableName > pgdump.sql 
like image 884
sheldonk Avatar asked Dec 16 '12 20:12

sheldonk


3 Answers

Here is the complete command to dump your table in plain mode:

pg_dump --host localhost --port 5432 --username "postgres" --role "postgres"  --format plain  --file "complete_path_file" --table "schema_name.\"table_name\"" "database_name"

OR you can just do:

pg_dump -t '"tablename"' database_name > data_base.sql

Look to the last page here: Documentation

like image 59
Houari Avatar answered Oct 19 '22 07:10

Houari


The above solutions do not work for me under Windows 7 x64. PostgreSQL 9.4.5. But this does, at last (sigh):

-t "cms.\"FooContents\""

either...

pg_dump.exe -p 8888 --username=user -t "cms.\"FooContents\"" basdb

...or...

pg_dump.exe -p 8888 --username=user -table="cms.\"FooContents\"" basdb
like image 12
Frank Nocke Avatar answered Oct 19 '22 07:10

Frank Nocke


Inside a cmd window, I had to put three (!) double quotes around the table name if it countains upper case letters. Example pg_dump -t """Colors""" database > database.colors.psql

like image 6
Dirk Zabel Avatar answered Oct 19 '22 07:10

Dirk Zabel