[20131104]通过pipe保存sqlplus的输出.txt

[20131104]通过pipe保存sqlplus的输出.txt

http://fritshoogland.wordpress.com/2013/10/31/compressing-sqlplus-output-using-a-pipe/

linux下通过pipe可以压缩保存sqlplus的输出,减少磁盘空间的占用。

例子:

mknod /tmp/oracle.pipe p

sqlplus -s scott/btbtms << _EOF
set escape on
set feedback off
set head off
set colsep '|'

host nohup gzip -c < /tmp/oracle.pipe > /tmp/out1.gz \&
spool /tmp/oracle.pipe
select * from emp;
spool off


_EOF

-- rm /tmp/oracle.pipe


$ less /tmp/out1.gz
      7369|SMITH     |CLERK    |      7902|1980-12-17 00:00:00|       800|          |        20
      7499|ALLEN     |SALESMAN |      7698|1981-02-20 00:00:00|      1600|       300|        30
      7521|WARD      |SALESMAN |      7698|1981-02-22 00:00:00|      1250|       500|        30
      7566|JONES     |MANAGER  |      7839|1981-04-02 00:00:00|      2975|          |        20
      7654|MARTIN    |SALESMAN |      7698|1981-09-28 00:00:00|      1250|      1400|        30
      7698|BLAKE     |MANAGER  |      7839|1981-05-01 00:00:00|      2850|          |        30
....

请使用浏览器的分享功能分享到微信等