Re: How to get pgsql to echo commands in a command file

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Michael Moore <michaeljmoore(at)gmail(dot)com>
Cc: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How to get pgsql to echo commands in a command file
Date: 2016-04-22 22:58:31
Message-ID: CAKFQuwZmN5xkZD==UCVARGLa2w9RmuoyXGrpgqxvkHvr4eY0Cg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Apr 22, 2016 at 3:50 PM, Michael Moore <michaeljmoore(at)gmail(dot)com>
wrote:

> I log into pgsql and then type:
> \i test.sql
>
> test.sql contains a single SELECT command and when I run that file I see
> the result of the select command.. The problem is, I also want to see the
> SELECT command itself.
>
> I've tried
> /echo
> /qecho
> and a lot of other commands, but nothing works.
>
> What do I need to do in order to see the commands in test.sql as well as
> the output of those commands on my pgsql window?
>
>
​\set ECHO all​

The \echo and \qecho commands​ commands only echo their arguments - they do
not effect the environment. You have to use "\set" or "\pset" (and some
other commands) if you want to affect the environment of subsequent
statements.

Or just invoke psql as "psql --echo-all" - optionally specifying the file
"psql --echo-all -f test.sql"

The documentation is quite good, if a bit long.

http://www.postgresql.org/docs/9.5/interactive/app-psql.html​

I'm running on Windows 7 if that matters.
>
>
​That would explain the forward slashes...

​David J.​

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Adrian Klaver 2016-04-22 22:58:35 Re: How to get pgsql to echo commands in a command file
Previous Message Michael Moore 2016-04-22 22:50:14 How to get pgsql to echo commands in a command file