eygle.com   eygle.com
eygle.com  
 

« Oracle中的不可见字符处理案例一则 | Blog首页 | 功夫熊猫 与 无师自通的领悟 »

使用Linux下script工具记录Oracle输出

作者:eygle |【转载时请以超链接形式标明文章和作者信息及本声明
链接:
在Linux下使用Oracle数据库时,很多时候我们想记录输出信息,当然有很多方法可以选择,但是这里我想说的是script工具。

在Linux下有一个script工具,可以将当前终端会话中的所有输入输出结果捕获到一个指定的文件里。
看一下这个工具的man输出:
[oracle@jumper oracle]$ which script
/usr/bin/script
[oracle@jumper oracle]$ man script
SCRIPT(1)                BSD General Commands Manual                SCRIPT(1)

NAME
    script - make typescript of terminal session

SYNOPSIS
    script [-a] [-f] [-q] [-t] [file]

DESCRIPTION
    Script makes a typescript of everything printed on your terminal.  It is
    useful for students who need a hardcopy record of an interactive session
    as proof of an assignment, as the typescript file can be printed out
    later with lpr(1).

    If the argument file is given, script saves all dialogue in file.  If no
    file name is given, the typescript is saved in the file typescript.

当然最重要的是看一下实际效果。

在记录操作前执行 script 命令开始记录,最后输入 exit 退出记录,中间的所有操作都会被记录下来,以下是一个测试过程,中间步骤被省略:
[oracle@jumper oracle]$ script
Script started, file is typescript
[oracle@jumper oracle]$ sqlplus "/ as sysdba"
<...ignore operation here...>
[oracle@jumper oracle]$ exit
Script done, file is typescript

现在让我们来看看记录文件typescript中记录了什么内容:
[oracle@jumper oracle]$ cat typescript
Script started on Thu 26 Jun 2008 07:56:18 AM CST
[oracle@jumper oracle]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on Thu Jun 26 07:56:24 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production

SQL> set linesize 120
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

Session altered.

SQL> col status for a8
SQL> col group# for 999999
SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS  FIRST_CHANGE# FIRST_TIME
------- ---------- ---------- ---------- ---------- --- -------- ------------- -------------------
      1          1        14    1048576          1 YES INACTIVE    1.9008E+10 2008-06-23 00:42:36
      3          1        15    1048576          1 YES INACTIVE    1.9008E+10 2008-06-25 14:29:37
      4          1        13    1048576          1 YES INACTIVE    1.9008E+10 2008-06-20 14:56:12
      5          1        16    1048576          1 NO  CURRENT    1.9008E+10 2008-06-25 15:58:38

SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
[oracle@jumper oracle]$
[oracle@jumper oracle]$ exit

Script done on Thu 26 Jun 2008 07:57:38 AM CST

这个工具是不是很有用途呢?
当然还有更强悍的 scriptreplay 工具可以replay script,不过缺省一般不带,不说了。

-The End-


历史上的今天...
      >> 2007-06-26文章:
             摄影习作-小小的太阳
      >> 2006-06-26文章:
             DB2新手上路:DB2命令行连接
             试用IBM DB2 Enterprise Server V9.0
             Oracle9iR2 NF:压缩表技术
      >> 2005-06-26文章:
      >> 2004-06-26文章:
             Oracle诊断案例-Spfile案例一则
             Oracle诊断案例-Sql_trace之二
             Oracle诊断案例-Sql_trace之一
------
这篇 【使用Linux下script工具记录Oracle输出】来自 www.eygle.com | CSDN技术网摘| del.icio.us|365Key

By eygle on 2008-06-26 10:39 | Comments (6) | Posted to FAQ | Tools | Edit |Pageviews:

相关文章 随机文章
  • 使用kudzu命令查看网卡型号
  • Tools:Linux下的SYSSTAT工具
  • Linux + Oracle 数据库系统启动能有多快?
  • 将出席Quest的数据库开发及管理研讨会
  • MemTest-一款小巧的内存测试软件
  • 2月份的最后一天
    Got Windows Live Mail Invitation
    Oracle HTML DB足够稳定么?
    上海滩
    获得Redo Block Size的非典型方法
    搜索本站:

    留言 (6)

    typescript 文件默认是当前路径吧?

    Posted by: wangliang at June 26, 2008 9:31 AM

    是,也可以指定输出文件路径的

    Posted by: eygle at June 26, 2008 12:07 PM

    第一次看到这个命令
    又长见识了.

    Posted by: xhy at June 26, 2008 6:50 PM

    学习!!

    Posted by: gaogao at June 27, 2008 5:51 PM

    aix is the same.

    Posted by: reed at June 29, 2008 11:45 AM

    SQL Handler -用 Java 开发的、专门用于 Oracle 数据库操作的一种图形界面工具: 多线程、多连结、支持 PL/SQL、功能实用、操作方便、界面简洁清新,能运行于所有平台包括 Windows、Linux 及 Unix,勿需安装 Oracle 客户端,只需一个 2.3 MB 的可执行 JAR 文件 SQLHandler.jar 及帮助文件 Help.html

    有意者请联系: mao.swan@163.com

    主要功能有:

    以表格的形式显示 Select SQL 语句的查询结果,可以直接对查询结果进行再操作,如修改、插入、删除、保存、多功能拷贝、导出、行列移动、列排序等;能对大型的文本字段(如 CLOB, LONG)查看、编辑等

    运行命令 "desc tablename" 能清楚地显示表 Table 的所有字段 Field (包括名称、数据类型及长度、默认值、非空)、所有的索引 Index、所有的约束条件 Constraints(主键、唯一键、检查键、子表、外键、甚至外键的外键)

    支持多条SQL语句的成批运行,用控制台监控每条语句的运行,在运行过程中可以中断/暂停/继续正在运行的 SQL、甚至可以更正出错误的 SQL,从而提高操作效率

    支持彩色文本编辑,即关键字、注释块、引号内字符串、操作符等,用不同的彩色字体加以区别; 还有,如果光标停在括号处,高亮度显示配对的括号,增强可读性
    方便高效的行块和列块操作,能对行块和列块中的文本进行拷贝、剪切、删除、左右移动等,以满足特殊需求

    全面支持 PL/SQL(包括 Procedure、 Function、Trigger、 Package),能够显示 DBMS_OUPTPUT.PUT_LINE 的输出;能够给出错误信息,甚至光标能够精确定位错误所在的行列位置,极大地方便于调试

    提供对常用数据字典(如 Tables、Views、Indexes 等)通配符查询、删除、修改等

    Posted by: Anonymous at November 13, 2008 1:06 PM

    发表留言:



    Remember Me?
    (输入验证码后方可评论,谢谢支持)



    CopyRight © 2004 eygle.com, All rights reserved.