Sample Header Ad - 728x90

copy command in postgresql to append data

5 votes
3 answers
17961 views
I am executing copy command from a function execute 'copy (select * from tableName) to ''/tmp/result.txt''' It works fine. But, `tableName is dynamic and will be having more tables (iterating in a loop). result.txt` is having only the last iteration (table) data. I could do, if I had to, via the command line with `\o or >>` by appending to a file. But, I have to use the function. I read http://shuber.io/reading-from-the-filesystem-with-postgres/ . It suggests a solution using temporary tables. Can I do something similar, but without temp tables? (I must avoid archive logs). Will creating a temp table create archive logs? Is there any way to do appending with `copy` command in a function?
Asked by RBB (815 rep)
Sep 15, 2016, 05:18 AM
Last activity: Oct 17, 2023, 11:18 AM