我试图在一行中运行以下查询:
x
select * from pg_stat_statements order by max_exec_time desc limit 10;
如下:
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;'
但我有
unrecognized value "select" for "expanded"
Available values are: on, off, auto.
command terminated with exit code 1
如何将x
和SQL查询结合起来?
另一种选择是多次使用-c
选项:
psql -c 'x' -c 'SELECT ...'
您也可以从命令行设置expanded
模式:
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;'