PostgreSQL:没有页眉/页脚行的选择语句

StO*_*cha 3 postgresql psql

select distinct table_schema from information_schema.tables;
Run Code Online (Sandbox Code Playgroud)

提供类似的东西

   table_schema    
--------------------
 mySchema
 pg_catalog
 information_schema
 anotherSchem
(4 rows)
Run Code Online (Sandbox Code Playgroud)

如何修改命令,以便看不到前两行(table_schema 和 ---)或最后一行(... rows)?

我在 bash 脚本中使用 psql 命令。我怎样才能\pset tuples ...在那里添加?

Lau*_*lbe 6

在 shell 脚本中,您可以使用psql选项--tuples-only(shorter -t),这比使用更方便\pset

psql -t -c 'SELECT ...'
Run Code Online (Sandbox Code Playgroud)

如果您只对单个查询结果感兴趣,通常最好也取消对齐和状态消息:

result="$(psql -Atq -c 'SELECT ...')"
Run Code Online (Sandbox Code Playgroud)