- #!/bin/bash
- x=`sqlplus user/password <
- select 'KEEP', count(1) from tab;
- exit
- end`
- echo the number of tab is $x
说明 [ ]之间的是空格+TAB, 如果在select中使用v$session, 则要用 "V\\\$SESSION"
count(1)和count(*)的效果是一样的
- sqlplus / @myscript.sql | read var1 var2 var3
- sqlplus / @myscript.sql | while read var1 var2 var3
- do
-
- done
- A specific example:
- In test.sql:
- set head off
- set verify off
- set feedback off
- set pages 0
- select 'number',count(1),count(*) from tab;
- exit;
- In test.sh:
- #!/bin/bash
- sqlplus system/manager @test.sql |grep number| while read i no nn
- do
- echo " echo $i is $no is $nn"
- done
转自:
阅读(4527) | 评论(0) | 转发(0) |