Re: psql output result

From: Tiffany Thang <tiffanythang(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: psql output result
Date: 2018-03-15 20:40:31
Message-ID: CAB_W-NPbBERZjQ52W-fsB1wYE9VzskdBL4Hax9OfSF3qEkEgzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks Geoff and Adrian!

On Thu, Mar 15, 2018 at 11:03 AM, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 03/15/2018 07:57 AM, Tiffany Thang wrote:
>
>> Hi,
>> I have a SQL script that does some DDLs, inserts and counts.
>>
>> The command I ran is
>> psql dbname -c "\i crscript.sql" > output.txt
>>
>> In output.txt, I got something like
>> INSERT 0 1
>> INSERT 0 1
>> CREATE TABLE
>> INSERT 0 2
>> count
>> -------
>> 9
>> (1 row)
>>
>>
>> Is there a way to output the SQLs and DDLs so that I could easily
>> identify what statements were executed?
>>
>
> aklaver(at)tito:~> psql -d test -U aklaver -a -f sql_test.sql
> \pset null 'NULL'
> Null display is "NULL".
> CREATE TABLE tbl_test(fld_1 int, fld_2 varchar);
> CREATE TABLE
> INSERT INTO tbl_test VALUES (1, 'dog'), (2, 'cat');
> INSERT 0 2
> DROP TABLE tbl_test;
> DROP TABLE
>
>
>> Thanks.
>>
>>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2018-03-15 20:48:51 Re: SELECT .. FOR UPDATE: find out who locked a row
Previous Message David G. Johnston 2018-03-15 20:38:03 Re: SELECT .. FOR UPDATE: find out who locked a row