如何从root到db2inst1 su调用一个SQL脚本? [英] How can I su from root to db2inst1 and invoke a SQL script, in one line?

查看:393
本文介绍了如何从root到db2inst1 su调用一个SQL脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 root db2inst1 并在一行中调用一个SQL脚本?我在想这样的事情:

How can I su from root to db2inst1 and invoke a SQL script all in 1 line? I am thinking about something like this:

su db2inst1 | db2 CONNECT TO myDatabase USER db2inst1 USING mypw; db2 -c -i -w -td@ -f /tmp/deploy/sql/My.sql | exit;

任何想法?

推荐答案

您可以使用 -c - command =< command> 执行 su 命令。在你的情况下,这样的东西:

You can use the -c or --command=<command> option to execute a command with su. In your case, something like this:

su -c 'db2 CONNECT TO myDatabase USER db2inst1 USING mypw; db2 -c -i -w -td@ -f /tmp/deploy/sql/My.sql' db2inst1

这篇关于如何从root到db2inst1 su调用一个SQL脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆