sqlplus与shell结合–shell中执行sql脚本。
su – oracle
使用oracle 用户执行
[oracle@dba ~]$ cat a.sh
#!/bin/bash
tab=emp
sqlplus -s scott/tiger << eof | awk 'nr != 1 && $2 ~ /s.*t/{print $2,$6}'
set head off
set feed off
select * from $tab;
select * from dept;
exit;
eof
[oracle@dba ~]$ ./a.sh
smith 800
scott 3000
[oracle@dba ~]$