本文总结了几种在SHELL脚本中调用Trafodion SQL语句的方法,供读者参考~
这里假设执行SHELL脚本的用户为trafodion用户,调用方法示例如下,如果执行SHELL脚本的用户为非trafodion用户,需要在脚本中另外添加一些su到trafodion用户的步骤,在此不做详述。
[trafodion@n12 ~]$ cat test.sh
#method 1
echo "
select count(*) from trafodion.seabase.test_table;
exit;
" | trafci
#method 2
trafci < /home/trafodion/test.sql
#method 3
$MY_SQROOT/trafci/bin/trafci.sh -h n12:23400 -u zz -p zz -s "/home/trafodion/test.sql"
[trafodion@n12 ~]$ cat test.sql
select count(*) from trafodion.seabase.test_table;
exit;
下面一个例子是通过SHELL脚本并发执行SQL查询,并发数即For循环的次数,
for ((i=0;i<50;i++));
do
sleep 1
trafci < single.sql >> log.txt &
echo `date`
done
exit