Linux/Unix shell sql ????????
???????????? ???????[ 2013/6/19 10:00:17 ] ????????
?????????Linux/Unix Shell ??SQL ???????????????????????DBA?????Ч??????????Linux/Unix shell sql ???????????????????????????ο???
????Linux/Unix ?μ???SQL??RAMN ??ο???Linux/Unix shell ????е???SQL??RMAN???
??????????
????1??shell????????sql??????????
oracle@SZDB:~> more ./retval.sh
#!/bin/bash
RETVAL=`sqlplus -silent scott/tiger <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
SELECT * FROM emp WHERE ename='SCOTT';
EXIT;
EOF`
if [ -z "$RETVAL" ]; then
echo "No rows returned from database"
exit 0
else
echo $RETVAL
fi
oracle@SZDB:~> chmod u+x retval.sh
oracle@SZDB:~> ./retval.sh
7788 SCOTT ANALYST 7566 19-APR-87 34171.88 20
????2??shell????????sql???????????
oracle@SZDB:~> more ./retval_2.sh
#!/bin/bash
# Author : Robinson Cheng
# Blog : http://blog.csdn.net/robinson_0612
sqlplus -S "scott/tiger" <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
col cnt new_value v_cnt
SELECT count(*) cnt FROM emp WHERE deptno=10;
exit v_cnt
EOF
VALUE="$?"
echo "show rows for deptno 10:$VALUE"
????3????shell????????????????sql???
oracle@SZDB:~> more ./retval_3.sh
#!/bin/bash
v_empno="$1"
sqlplus -S "scott/tiger" <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
SELECT ename FROM emp WHERE empno=$v_empno;
exit
EOF
exit
oracle@SZDB:~> ./retval_3.sh 7788
SCOTT
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11