如何使用 -f 选项将 sql 脚本文件列表传递给 psql

how to pass list of sql scripts files to psql using -f option

我想知道我们是否可以使用 psql 命令传递 sql 脚本文件列表。

我有 test1.sql、test2.sql、test3.sql 个文件,现在我正在循环中单独执行这些文件

psql -f D:\test1.sql postgresql://postgres:secret@localhost:5432/testdb

我想知道是否有任何方法可以将所有三个文件传递给 psql 命令并且 psql 应该顺序执行。

您可以多次使用-f参数:

psql -f D:\test1.sql -f D:\test2.sql -f D:\test3.sql postgresql://postgres:secret@localhost:5432/testdb