简体   繁体   English

如何在PostgreSQL中的函数内使用\\ COPY命令

[英]How to use \COPY command inside a function in PostgreSQL

I want to export the table into a .CSV file using \\COPY command. 我想使用\\ COPY命令将表导出到.CSV文件中。 I can able to do that as a stand-alone command. 我能够做到这一点作为一个独立的命令。 I can't embed the same line inside a function in PostgreSQL. 我无法在PostgreSQL中的函数中嵌入相同的行。 Actually that call should come from a ECPG. 实际上这个电话应该来自ECPG。 I chose \\COPY over COPY command as I don't have super-user account! 我选择\\ COPY over COPY命令,因为我没有超级用户帐户! Please guide me on this. 请指导我这个。

Thanks and Regards, Siva. 谢谢和问候,西瓦。

Unfortunately, all of the \\ commands are psql commands. 不幸的是,所有的\\ command都是psql命令。 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. 您可以运行psql -E来查看这些命令扩展到哪些命令并将其发送到服务器,但是如果您需要一个超级用户帐户来运行COPY ,那么您将需要一个超级用户帐户来执行此操作。

If you are talking about using copy with plpgsql, I think this might help: 如果你正在谈论使用plpgsql复制,我认为这可能会有所帮助:

Dynamically-generated table-name in PostgreSQL COPY command PostgreSQL COPY命令中动态生成的表名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM