4

I want to export the table into a .CSV file using \COPY command. I can able to do that as a stand-alone command. I can't embed the same line inside a function in PostgreSQL. Actually that call should come from a ECPG. I chose \COPY over COPY command as I don't have super-user account! Please guide me on this.

Thanks and Regards, Siva.

2 Answers 2

1

Unfortunately, all of the \ commands are psql commands. You can run psql -E to see what those commands expand into and get sent to the server as, but if you need a super-user account to run COPY, you're going to need a super-user account to do this.

Sign up to request clarification or add additional context in comments.

2 Comments

It expands to COPY TableName FROM STDIN, but I have no idea how to redirect CSV file into standard input stream within function's body (as non-superuser of course).
You would probably be better served by copying your file into /tmp and asking PostgreSQL to COPY FROM /tmp/your-filename.
0

If you are talking about using copy with plpgsql, I think this might help:

Dynamically-generated table-name in PostgreSQL COPY command

1 Comment

Hi, I want to use \COPY command (as I don't have super-user with me) in the STATEMENT. Is that possible? It is not allowing me inside the function. Please guide me.

Your Answer

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.