I have a bytea
column in PostgreSQL DB which holds PDF files.
How can I export that file using psql
?
I tried:
psql -U <USER> -h <HOST> -p <PORT> -d <DB> -c "\copy (select <column> from <table> where <column> = <id>) to STDOUT with BINARY;" > output.pdf
That saves the file and I can open it in a PDF reader. But when I check the file with hexdump -C output.pdf | head
, I see it has a header starting with PGCOPY
.
How can export that file without PGCOPY
header?