Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: Outputting query of underlying function

Tags:

postgresql

Someone once mentioned a way to make Postgres verbose, so that if you did \dt it would display all the underlying SQL.

I thought it was connected with -a or -e to echo the SQL, but I was wrong. I seem to have forgotten that method and have tried to look it up without any luck:
http://www.postgresql.org/docs/current/static/app-psql.html


Edit:

I thought because this was database/sql related it was for stackoverflow, but this may need to be moved to [Super Users|Server Fault|Database Administrators] (?)

like image 285
vol7ron Avatar asked Sep 03 '26 02:09

vol7ron


2 Answers

To show the queries of internal commands,

Method 1 : psql -E - including -E option while opening the console.

Method 2 : \set ECHO_HIDDEN noexec/on/off, can be used while in session. noexec means it doesn't run the query, just prints it.

like image 83
Vignesh Raja Avatar answered Sep 06 '26 17:09

Vignesh Raja


snipped from the output of psql --help:

  -e, --echo-queries       echo commands sent to server
  -E, --echo-hidden        display queries that internal commands generate
like image 41
wildplasser Avatar answered Sep 06 '26 17:09

wildplasser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!