我有一个包含至少 6 个函数文件的目录。
我正在使用 psql,我需要能够一次获取(初始化?)所有函数文件。
我确定制作一个函数并调用所有其他函数,如 SELECT fn1, fn2
是行不通的。
执行 \i functions_folder/fn1.sql
6 次也不理想。
那么有什么方法可以(也许)\i functions/*.sql
?这样做目前给了我
functions/*.sql: 没有那个文件或目录
我在 postgresql 9.6.2 上使用 psql
最佳答案
如果您使用的是 *nix 操作系统:
postgres=# \! cat ./functions/*.sql > all_functions.sql postgres=# \i all_functions.sql
对于 Windows,尝试找到 cat
的类似物(我记得它是带有一些标志的 copy
命令)
PS 我觉得可以通过使用反引号来完成:
Within an argument, text that is enclosed in backquotes (`) is taken as a command line that is passed to the shell. The output of the command (with any trailing newline removed) replaces the backquoted text.
但是还是不知道怎么办。可能更有经验的人会提供提示......
关于postgresql - 如何在 psql 中获取多个函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43816381/