当前位置:网站首页>Using sqlplus to operate database in shell script
Using sqlplus to operate database in shell script
2022-08-10 05:46:00 【DOCKER007】
Oracle client installation steps are shown in the blog post: CSDN
shell operation database tool script: https://download.csdn.net/upload/10975286
When operating the database in the shell script, you can use sqlplus
#Set database connection string
conn=user/[email protected]:1521/SID#define sql
sqlstr="select sysdate from dual;"#Execute sql and get the result
sql_exc=$( sqlplus $conn < $sqlstr commit; exit; EOF )#echo "sql execution result:"$sql_exc This method can get a lot of results, in addition to sql query results, there are also many version information and many other irrelevant characters, it is difficult to get the query results So modify it to the following code, which solves many problems of printing results, and only prints the results to be queried. #Set database connection string conn=user/[email protected]:1521/SID#define sql sqlstr="select sysdate from dual;"#Execute sql and get the result sql_exc=$( sqlplus -s /nolog < set echo off feedback off heading off underline off; conn $conn; $sqlstr commit; exit; EOF )#echo "sql execution result:"$sql_exc
边栏推荐
猜你喜欢
随机推荐
【论文笔记1】小样本分类
AWR1843型号毫米波雷达使用
Buu Web
图片批量添加水印批量加背景缩放批量合并工具picUnionV4.0
Pony语言学习(一):环境配置(续)
最新最全的数字藏品发售日历-07.26
shell脚本中利用sqlplus操作数据库
redis---非关系型数据库(NoSql)
The complex "metaverse" will be interpreted for you, and the Link Reading APP will be launched soon!
pytest测试框架
网安超基础一周目
再肝3天,整理了90个 NumPy 例子,不能不收藏!
文章复现:超分辨率网络-VDSR
三维点云分割
R中设置图形参数--函数par()详解
反转链表中的第m至第n个节点---leetcode
2021-07-09
PCL点云滤波
链读|最新最全的数字藏品发售日历-08.02
第五次实验