ZFlyGuy
ZFlyGuy

Reputation: 99

How do I copy a mixed or fully upper case table name from one postgres database to another?

I am having some difficulty getting a table with an entirely uppercase name to copy from one postgres database to another.

Based on posts here and elsewhere, I have been using the following syntax at command line:

pg_dump -t tablename fromdb | psql todb

The database names are all in caps as well, though that hasn't proven to be an issue.

Here is the line I need to run more or less:

pg_dump -t "COMMS" "DB_V1" | psql "DB_V2"

When transferring a table with a name that is all lowercase in double quotes (as a test case) it works perfectly and has no problem with the database names being all caps and double quotes. When trying to transfer a table name that is in all caps however, it cannot find it. "pg_dump: No matching tables were found"

Based on reading elsewhere, I've tried using '"COMMS"', as well as different permutations just to see if they would work. Based on that reading, I really expected the double quotes inside single quotes to work.

Is there an established practice for this that I am missing in my research? I realize there is likely a very simple answer out there. Thanks in advance!

Upvotes: 4

Views: 1992

Answers (1)

pirimoglu
pirimoglu

Reputation: 328

Adding backslash before double quotes works at windows cmd shell

pg_dump -t \"TableName\" MYDB

Upvotes: 5

Related Questions