linux shell 查询oracle数据库中的值 并返回
程序员文章站
2022-07-13 21:37:04
...
#!/bin/bash dbserver=10.21.2.152 port=1521 username=COLDB2 password=creditderivative sid=orcl select_sql="select count(*) as rowsCount from f3distcalccounter;" rowsCount=`sqlplus -s ${username}/${password}@${dbserver}:${port}/${sid} <<EOF set pagesize 0 heading off echo off termout off feedback off linesize 1200 colsep "," trimspool on trimout on ${select_sql} quit; EOF` echo ${rowsCount}
1 : sqlplus 后面的 -s 很重要
2:
set pagesize 0 heading off echo off termout off feedback off linesize 1200 colsep "," trimspool on trimout on
更多的可以参考 :
http://jingyan.baidu.com/article/c35dbcb0f104448917fcbc72.html