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""

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

1 Answer 1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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