免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 505 | 回复: 0
打印 上一主题 下一主题

[其他] shell 与sql如何混合使用? [复制链接]

论坛徽章:
2
15-16赛季CBA联赛之广东
日期:2016-07-17 21:29:0415-16赛季CBA联赛之吉林
日期:2016-12-28 15:54:19
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-09-03 16:30 |只看该作者 |倒序浏览
sql能否直接使用shell脚?
比如:
while read a
do

if [ a -le 4]
then
sqlplus sys/oracle@wyln as sysdba <<!
select a,b,c from tables 1 into temp a;
unload to 1.txt select * from a
!
fi
if [ a -le 4]
then
sqlplus sys/oracle@wyln as sysdba <<!
select a,b,c from tables 1 into temp a;
unload to 1.txt select * from a
!
fi

if [ a -gt 4]
then
sqlplus sys/oracle@wyln as sysdba <<!
select a,b,c from tables2 into temp a;
unload to 1.txt select * from a
!
fi
if [ a -le 4]
then
sqlplus sys/oracle@wyln as sysdba <<!
select a,b,c from tables 1 into temp a;
unload to 2.txt select * from a
!
fi
cat 1.txt 2.txt>>3.txt
sqlplus sys/oracle@wyln as sysdba <<!
load from 3.txt insert into temp a;
!
done<sj.txt
以上功能要实现根据不同a的大小查询不同的表,并把数据插入到一张临时表中。但每次都要开关数据库,能不能只开一次数据库,就可执行完毕?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP