gpt4 book ai didi

command-line - 如何在 postgreSQL linux 中执行多个 sql 文件?

转载 作者:行者123 更新时间:2023-12-04 16:10:15 25 4
gpt4 key购买 nike

我在 linux debian 的文件夹 (/home/myHSH/scripts) 中有许多 .sql 文件。我想知道将文件夹内的所有 sql 文件执行或运行到 postgreSQL v9.1 数据库中的命令。

PostgreSQL 信息:

Database name=coolDB
User name=coolUser

很高兴:如果您也知道如何通过 pgAdmin3 之类的 GUI 工具执行多个 sql 文件。

最佳答案

从您的命令行,假设您使用的是 Bash 或 ZSH(简而言之,除了 csh/tcsh 之外的任何东西):

for f in *.sql;
do
psql coolDB coolUser -f "$f"
done

关于command-line - 如何在 postgreSQL linux 中执行多个 sql 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13062168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com