2

I have some text like xml -code in a field of table. I want to export the data from my field into file without any changes.

I've tried to use a lot of variants but all of them changes the text. The most successful variants were:

COPY (SELECT alll FROM super.a_a ) TO 'D:\alll.txt' CSV ;

But there appeared extra quotes "".

COPY (SELECT alll FROM super.a_a ) TO 'D:\alll.txt CSV QUOTE ' ' ;

But there appeared extra spaces.

In my field I have such date like : name="firsname" and when I use any of varients I get something like that : name=""firstname"" or name=\n\r"firstname\n\r""

  • COPY is always tied to a format. For no format whatsoever, use SELECT and let your client software direct the results into a file. – Daniel Vérité Jun 29 '16 at 12:54
  • Just remove CSV to export to the pure text format. – Abelisto Jun 29 '16 at 14:05
  • @Abelisto: No. In the non-CSV COPY format, backslashes are doubled and control characters are output as backslash-style sequences. – Daniel Vérité Jun 29 '16 at 15:17
0

Maybe, you can just execute the query in psql and redirect its output to a file after removing all headers. Did you try something like:

$ psql
user=> \o outputfile.txt
user=> \t on
user=> SELECT alll FROM super.a_a;
user=> \q

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.