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

Daniel Vérité
32.8k3 gold badges78 silver badges84 bronze badges
asked Jun 29, 2016 at 12:30
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. Commented Jun 29, 2016 at 12:54
  • Just remove CSV to export to the pure text format. Commented 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. Commented 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
answered Apr 19, 2019 at 9:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.