I'm trying to run the following queries in one line:
\x
select * from pg_stat_statements order by max_exec_time desc limit 10;
As follows:
kubectl -n MYNAMESPACEXXX exec -ti MYPGPOD-K8SXXX -- psql -d MY-DB -U postgres -c '\x select * from pg_stat_statements order by max_exec_time desc limit 10;'
But I get
unrecognized value "select" for "expanded"
Available values are: on, off, auto.
command terminated with exit code 1
How can we combine both \x
and the SQL query ?
CodePudding user response:
An alternative is to use the -c
option several times:
psql -c '\x' -c 'SELECT ...'
CodePudding user response:
You can also set the expanded
mode from the commandline:
kubectl -n MYNAMESPACEXXX exec -ti MYPGPOD-K8SXXX -- psql -d MY-DB -U postgres --expanded -c 'select * from pg_stat_statements order by max_exec_time desc limit 10;'