当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
手把手带你写嵌入式物联网的第一个项目
opencv
行盒子的盒模型
Tkinter 入门之旅
在yolov5的网络结构中添加注意力机制模块
基于Qiskit——《量子计算编程实战》读书笔记(四)
SEO搜索引擎优化
毫米波雷达基础概念学习
PCL,VS配置过程中出现:用 _sopen_s 代替 _open, 或用_CRT_SECURE_NO_WARNNINGS错误
Qiskit 学习笔记1
k-近邻实现手写数字识别
matlab中的常用的类型转换
小记录:Pytorch做深度学习必要加载的包
从GET切换为POST提交数据的方法
安装Robotics-toolbox-matlab, for 点云坐标系转换
pytorch框架学习(6)训练一个简单的自己的CNN (三)细节篇
cesium 添加点,移动点
cesium 旋转图片
网络安全作业
pytorch框架学习(5)torchvision模块&训练一个简单的自己的CNN (二)