Postgresql:在使用 \d+ <table_name> 命令显示的同时下载架构?

Postgresql : download schema at the same time while showing using \d+ <table_name> command?

我知道可以使用 pg_dump -U postgres -h localhost -d crm -h localhost -s > exp.dmp 下载架构。但是,这并没有提供有关外键的正确信息,table 指的是当前的 table。

但是当我使用 \d+ <table_name> 时,它会显示有关带外键的数据库的所有信息,其中 table 指的是当前 table.

现在的问题是如何下载此 \d+ <table_name> 输出。我尝试使用 \d+ <table_name> > abc.dmp ,但不起作用。有执行此操作的命令吗?

P.S。我在 Linux(Ubuntu 16.04)

上工作

查看 psql 帮助 (\?):

\o [FILE]              send all query results to file or |pipe

示例:

test=# \o a_table.txt
test=# \d+ a_table
test=# \q
$ more a_table.txt

PS。使用不带参数的 \o 将其关闭。