本文介绍了我们如何在shell脚本中进行数据库连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在写一个shell脚本,它处理DB(Oracle)表操作(创建,更新,更改,插入等...)

对于每个操作我都写了单独的shell脚本函数。

请告诉我,有必要在下面的每一个函数中连接到oracle吗?



sqlplus -s scott / tiger<< EOF



请告诉我这个数据库连接的范围是函数还是整个脚本?



我用这个语句编写了一个DB_Connection函数,其他函数从脚本中的main函数调用。

主函数包括DB_connection,Create_Table,inser_rows等...函数。



因此,在编写任何DDL语句之前,必须在每个函数中写入此行。

Eg

sqlplus -s scott / tiger<< EOF

选择*从< table_name>

退出

EOF





提前致谢。 :-O

解决方案

Hello,

I am writting a shell script, which handles DB(Oracle) table operations (create, update, alter, insert etc...)
For each operation I had written seperate shell script function.
Could you please tell me that, it is necessary to connect to oracle in every function with below line?

sqlplus -s scott/tiger << EOF

Please tell me the scope of this DB connection is functionwise or its overall to the script?

I had written a DB_Connection function with this statement and other functions are getting called from main function in script.
Main function includes DB_connection, Create_Table, inser_rows etc...functions.

So is it necessary to write this line in every function before writting any DDL statement.
E.g.
sqlplus -s scott/tiger << EOF
Select * from <table_name>
exit
EOF


Thanks in advance. :-O

解决方案


这篇关于我们如何在shell脚本中进行数据库连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 10:28
查看更多