PostgreSQL:单个表的 pg_dump

StO*_*cha 5 postgresql pg-dump

我是 PostgreSQL 的初学者,使用以下方法进行备份:

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

工作正常!现在我想备份方案“SchemeName”中的单个表“TableName”并尝试

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

pg_dump: no matching tables were found

如何让它发挥作用?

小智 9

当您有区分大小写的表和模式名称时,您必须正确引用表名称。下面的命令应该可以正常工作,因为我已经成功执行了它。

请确保在此命令中使用正确的区分大小写的数据库、架构和表名称。

./pg_dump --dbname="myDatabase" --host=localhost --port=5432 --username=postgres  --table='"MyScheme"."TableName 01"' --file=Dummy
Run Code Online (Sandbox Code Playgroud)

或者

./pg_dump --dbname="myDatabase" --host=localhost --port=5432 --username=postgres  --table='"MyScheme"."TableName 01"' > ~/Dummy.SQL
Run Code Online (Sandbox Code Playgroud)