Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you output comments in a postgres sql script

Tags:

sql

postgresql

I'm running a large sql script with postgres as follows:

psql < scriptname.sql

Each sql statement has a comment explaining (using -- syntax) what it does but it isnt output, and its difficult to match up each statement with output. I simply want to output the comments together with the results of the statements

like image 759
Paul Taylor Avatar asked Jan 18 '26 15:01

Paul Taylor


2 Answers

Search for the \echo command in the psql reference.

This is psql specific though...

like image 92
vyegorov Avatar answered Jan 20 '26 08:01

vyegorov


Turn echo on with

--echo-all

then use it with \echo type your text

\echo My comment
like image 32
Michaël Bué Avatar answered Jan 20 '26 09:01

Michaël Bué



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!