snippetsqlCritical
How to turn off header only in psql (postgresql)
Viewed 0 times
turnpostgresqlheaderpsqlhowonlyoff
Problem
I'm using PostgreSQL 9.1.X
I am trying to build
http://www.postgresql.org/docs/9.1/static/app-psql.html
From the document above
will turn both header and footer off. and
will turn footer off only.
Is there a way in
I know there are many ways to work around this issue using shell/perl/whatever text tool you like, however I am wondering why there is a config for the footer but not one for the header?
I am trying to build
psql script to print results without a header but including a footer. http://www.postgresql.org/docs/9.1/static/app-psql.html
From the document above
\pset tuples_onlywill turn both header and footer off. and
\pset footer offwill turn footer off only.
Is there a way in
psql to turn the header off and keep the footer on? I know there are many ways to work around this issue using shell/perl/whatever text tool you like, however I am wondering why there is a config for the footer but not one for the header?
id <--this line I don't want
---- <-- this line I don't want either
1 <-- this line, yes
(1 row) <-- yes, I want it!Solution
When executing
Within
psql from shell you can use -t (prints tuples only) option:$ psql -t -c "SELECT version();"
PostgreSQL 9.5.5 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bitWithin
psql use \t to turn off printing header and row count.Code Snippets
$ psql -t -c "SELECT version();"
PostgreSQL 9.5.5 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bitContext
StackExchange Database Administrators Q#24215, answer score: 56
Revisions (0)
No revisions yet.