[英]Is it possible to extract only tables starting with a specific name in pg_dump in Postgres?
Among the hundreds of tables in the postgres DB, only the structure dump of tables starting with a specific name is found.在 postgres DB 的数百个表中,仅找到以特定名称开头的表的结构转储。
Example例子
the name of the table表名
abc
abc_hello
abc_hi
def
def_hello
def_hi
If you think there is I want to dump only tables starting with abc*.如果您认为我只想转储以 abc* 开头的表。
pg_dump abc.txt -Fp -t abc* -s DBName
However, it was not recognized because the amount of tables was too large.但是由于表量太大,没有被识别。 it answered,
它回答说,
pg_dump: error: too many command-line arguments (first is "DBName")
but this command works fine但是这个命令工作正常
pg_dump abc_hello.txt -Fp -t abc_hello -s DBName
How can I pick them out?我怎样才能把它们挑出来?
Your main mistake is that you didn't consider that *
also is a special character for the shell. If you run您的主要错误是您没有考虑到
*
也是 shell 的特殊字符。如果您运行
pg_dump -t abc* mydatabase
the shell will replace abc*
with the names of all files in the current directory that start with abc
, so that your command will actually be something like shell 会将
abc*
替换为当前目录中以abc
开头的所有文件的名称,因此您的命令实际上类似于
pg_dump -t abcfile1 abcfile2 abcfile3 mydatabase
which is syntactically not correct and will make pg_dump
complain.这在语法上是不正确的,并且会使
pg_dump
抱怨。
You have to protect the asterisk from being expanded by the shell with single quotes:您必须使用单引号保护星号不被 shell 扩展:
pg_dump -t 'abc*' mydatabase
The other error in your command line is that you forgot the -f
in -f abc.txt
.命令行中的另一个错误是您忘记了
-f
in -f abc.txt
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.