分类: Oracle
2009-04-14 13:47:07
#标准输出设置,使用DBMS_OUTPUT.put_line()输出到屏幕。 #size 设置缓冲区大小。 set SERVEROUTPUT ON size 100000; #查询结果行数设置 set FEEDBACK OFF; #是否显示结果头信息 set HEADING OFF; #是否显示命令 set ECHO OFF; #如果设为0,则所有的输出内容为一页并且不显示列标题 set PAGES 0 #设置行长度 set LINESIZE 255 #输出格式 COL TABLE_NAME FORMAT a30; #查询结果定向到参数1指定的文件中 spool &1 declare NUM_COUNT NUMBER; BEGIN FOR CUR IN (SELECT * FROM USER_TABLES ) LOOP EXECUTE IMMEDIATE 'SELECT COUNT(*) INTO :NUM_COUNT FROM ' || CUR.TABLE_NAME INTO NUM_COUNT; DBMS_OUTPUT.PUT_LINE(CUR.TABLE_NAME || ',' || NUM_COUNT ); END LOOP; END; / spool off quit |
#/bin/sh #input # scrptnm: SQL script name # outflnm: Output file name #function # SQL running result runSQLS() { #input parameter if [ "$#" -lt 3 ]; then echo "use: ./0030.sh scrptnm outflnm" return fi #run SQL script ERRORBUF=`sqlplus apps/apps @$1 $2` echo "ERRORBUF: $ERRORBUF" } #shell main program #1, configure environment export ORACLE_SID=eoss export ORACLE_HOME=/app/eoss/eossdb/9.2.0 PATH=$PATH:$ORACLE_HOME/bin #call function runSQLS "$1" "$2" echo "run 0030.sh over..." |