ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20131119]sqlplus颜色输出.txt

[20131119]sqlplus颜色输出.txt

原创 Linux操作系统 作者:lfree 时间:2013-11-19 09:11:51 0 删除 编辑
[20131119]sqlplus颜色输出.txt

昨天别人问一个sqlplus色彩输出的问题,实际上以前我自己写过一个脚本,检查rman备份的情况:

内容如下:

column status format a16
column input_type format a11
column elapsed_seconds format 99999 head "ELAPSED|SECONDS"
column compression_ratio format 99.99999 head "COMPRESSION|RATIO"
column inputb format a12 head "INPUT BYTES| DISPLAY"
column outputb format a12 head "OUTPUT BYTES| DISPLAY"
column input format a12 head "INPUT BYTES|PER_SEC DISPLAY"
column output format a12 head "OUTPUT BYTES|PER_SEC DISPLAY"
column time format a10
column ok format a14
set linesize 200
SELECT start_time, end_time, elapsed_seconds,TRIM (time_taken_display) TIME, status, input_type,
       compression_ratio, TRIM (input_bytes_display) inputb,
       TRIM (output_bytes_display) outputb,
       TRIM (input_bytes_per_sec_display) input,
       TRIM (output_bytes_per_sec_display) output,
       DECODE (status,
               'COMPLETED', CHR (27) || '[1;32m' || 'V',
               CHR (27) || '[1;31m' || 'X'
              )||CHR (27) || '[0m' ok
  FROM v$rman_backup_job_details
 WHERE start_time > TRUNC (SYSDATE) - 12
 order by start_time desc ;
quit

输出的例子:
                                        ELAPSED                                         COMPRESSION INPUT BYTES  OUTPUT BYTES INPUT BYTES  OUTPUT BYTES
START_TIME          END_TIME            SECONDS TIME       STATUS           INPUT_TYPE        RATIO  DISPLAY      DISPLAY     PER_SEC DISP PER_SEC DISP OK
------------------- ------------------- ------- ---------- ---------------- ----------- ----------- ------------ ------------ ------------ ------------ ----------
2013-11-19 00:20:18 2013-11-19 00:21:32      74 00:01:14   COMPLETED        ARCHIVELOG      1.45321 749.02M      515.42M      10.12M       6.97M        V
2013-11-18 00:20:23 2013-11-18 00:21:55      92 00:01:32   COMPLETED        ARCHIVELOG      1.52757 839.37M      549.48M      9.12M        5.97M        V
2013-11-17 00:20:09 2013-11-17 08:23:02   28973 08:02:53   FAILED           DB FULL         3.56265 1.39T        400.65G      50.45M       14.16M       X
2013-11-16 00:20:17 2013-11-16 00:21:45      88 00:01:28   COMPLETED        ARCHIVELOG      1.41245 1.01G        731.91M      11.75M       8.32M        V
2013-11-15 00:20:17 2013-11-15 01:01:11    2454 00:40:54   COMPLETED        ARCHIVELOG      1.30648 46.58G       35.65G       19.44M       14.88M       V
2013-11-14 00:20:33 2013-11-14 01:16:27    3354 00:55:54   COMPLETED        ARCHIVELOG      1.30929 60.71G       46.37G       18.54M       14.16M       V
2013-11-13 11:23:35 2013-11-13 11:24:37      62 00:01:02   COMPLETED        SPFILE          1.00000 48.13M       48.28M       794.84K      797.42K      V
2013-11-13 00:20:18 2013-11-13 00:26:53     395 00:06:35   COMPLETED        ARCHIVELOG      1.30114 6.37G        4.90G        16.52M       12.70M       V
2013-11-12 00:20:15 2013-11-12 00:21:26      71 00:01:11   COMPLETED        ARCHIVELOG      1.57829 603.80M      382.57M      8.50M        5.39M        V
2013-11-11 00:20:16 2013-11-11 00:21:18      62 00:01:02   COMPLETED        ARCHIVELOG      1.54423 393.68M      254.94M      6.35M        4.11M        V
2013-11-10 00:20:10 2013-11-10 06:55:54   23744 06:35:44   COMPLETED        DB FULL         3.25490 1.18T        372.46G      52.28M       16.06M       V
2013-11-09 00:20:18 2013-11-09 00:22:02     104 00:01:44   COMPLETED        ARCHIVELOG      1.39767 912.69M      653.01M      8.78M        6.28M        V
2013-11-08 00:20:16 2013-11-08 00:21:38      82 00:01:22   COMPLETED        ARCHIVELOG      1.44176 753.84M      522.86M      9.19M        6.38M        V
2013-11-07 00:20:16 2013-11-07 00:21:42      86 00:01:26   COMPLETED        ARCHIVELOG      1.41592 1020.24M     720.55M      11.86M       8.38M        V

14 rows selected.


--实际上这个脚本仅仅在linux下使用,如果在windows依旧无法使用,当然解决方法很简单,就是使用rlwrap调用sqlplus,这样就可以了。
--rlwap的windows版本比较难找,我写过一篇"如何提高命令行的工作效率增强版"的文章,链接如下,里面有rlwrap的windows版本的下载。

http://www.itpub.net/forum.php?mod=viewthread&tid=1155109

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-776903/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    2673
  • 访问量
    6432628