Bertie
Bertie

Reputation: 17697

Copying csv from database into a new table

I understand that postgres can copy a csv file from the filesystem into a table like this:

COPY my_table
FROM '/home/xxx/test.csv' 
DELIMITER ',' 
CSV HEADER;

I am wondering whether i can load a csv file that is stored as a bytea in another table ? Maybe something like:

COPY my_table
FROM (select my_csv_bytea from my_csv where id = 1)
DELIMITER ',' 
CSV HEADER;

Upvotes: 1

Views: 40

Answers (1)

Adrian Klaver
Adrian Klaver

Reputation: 19724

No as bytea is not CSV. You would have to extract the bytea field and convert it into its CSV form and then you could load it into the table.

Upvotes: 2

Related Questions