bash - 在 shell 脚本中连接到 sqlplus 并运行 SQL 脚本

标签 bash shell sqlplus

我有一个 .sql 文件,它是一堆 oracle pl/sql 命令,我想创建一个 shell 脚本来运行这些命令。

假设 user/pass@server 是我的凭据。执行此类任务的 shell 脚本是什么?

最佳答案

例如:

sqlplus -s admin/password << EOF
whenever sqlerror exit sql.sqlcode;
set echo off 
set heading off

@pl_script_1.sql
@pl_script_2.sql

exit;
EOF

关于bash - 在 shell 脚本中连接到 sqlplus 并运行 SQL 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10277983/

相关文章:

linux - 用 bash 设置参数

linux - 如何在 Linux 中打印与我的排序结果相关的所有行

linux - sed如何在匹配模板时插入2次替换?

python - Sha-bang 行给出的结果与手动调用脚本不同

oracle - 在SQL * Plus中,如何更改提示以显示已连接的用户和数据库?

sql - 如何删除 SQL Plus 假脱机中不必要的换行符?

bash - 使用 tshark grep tcpdump

python - 如何从 django/wsgi 中调用 bash 进程?

shell - 推荐的 POSIX sh shebang 是什么

shell - 使用反引号时如何在 KornShell 脚本中保留空格?