Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

In Postgres, how to preserve newline character in COPY TO command?

$
0
0

One of the column of my table contains string with ‘n’.

postgres=# select * from stringtest ;

 id |    inputstr

----+-----------------

  1 | Name : NOCr   +

    | r             +

    | Detail : Detail

(1 row)

But when I retrieve same table with COPY TO, new line character is getting escaped

postgres=# COPY (select * from stringtest) TO STDOUT WITH DELIMITER E't' ;

1       Name : NOCrnrnDetail : Detail

How can I make COPY TO command to replace ‘n’ with new line ??

Expected output :

postgres=# COPY (select * from stringtest) TO STDOUT WITH DELIMITER E't' ;

1       Name : NOCr
        r
        Detail : Detail

How to achieve this ??


Viewing all articles
Browse latest Browse all 1138

Trending Articles