[20120106]使用bash shell显示隐含参数.txt

简介: 我个人喜欢使用putty打开两个窗口,一个执行sql语句,另外一个查看目录user_dump_dest下的trc文件。如果要查询隐含参数,往往要切换sys用户,执行一个脚本:$ cat hide.
我个人喜欢使用putty打开两个窗口,一个执行sql语句,另外一个查看目录user_dump_dest下的trc文件。
如果要查询隐含参数,往往要切换sys用户,执行一个脚本:

$ cat hide.sql
col name format a36
col description format a66
col session_value format a22
col default_value format a22
col system_value format a22

select
   a.ksppinm  name,
   a.ksppdesc DESCRIPTION,
   b.ksppstdf DEFAULT_VALUE,
   b.ksppstvl SESSION_VALUE,
   c.ksppstvl SYSTEM_VALUE
from sys.x$ksppi a, sys.x$ksppcv b, sys.x$ksppsv c
where a.indx = b.indx
 and a.indx = c.indx
 and a.ksppinm like '%&1%'
order by 1;

这样操作比较麻烦,今天写了一个shell函数,放在.bash_profile文件中,内容如下:

P() {
echo '  '
if [ -z "$1" ]; then
sqlplus -S "/ as sysdba" set echo off lin 9999 trimsp on feedb off head on pages 0 newp 0 tab off
col name for a36
col description format a76
col default_value format a10
col session_value format a20
col system_value format a20
select a.ksppinm name, a.ksppdesc DESCRIPTION, b.ksppstdf DEFAULT_VALUE, b.ksppstvl SESSION_VALUE, c.ksppstvl SYSTEM_VALUE from sys.x\$ksppi a, sys.x\$ksppcv b, sys.x\$ksppsv c where a.indx = b.indx and a.indx = c.indx and upper(a.ksppinm) like upper('%$1%') order by 1;
EOF

else
sqlplus -S "/ as sysdba" set echo off lin 9999 trimsp on feedb off head on pages 0 newp 0 tab off
col name for a36
col description format a76
col default_value format a10
col session_value format a20
col system_value format a20
select a.ksppinm name, a.ksppdesc DESCRIPTION, b.ksppstdf DEFAULT_VALUE, b.ksppstvl SESSION_VALUE, c.ksppstvl SYSTEM_VALUE from sys.x\$ksppi a, sys.x\$ksppcv b, sys.x\$ksppsv c where a.indx = b.indx and a.indx = c.indx and upper(a.ksppinm) like upper('%$1%') order by 1;
EOF

fi
echo '  '
}

这样直接在shell调用就可以了。注意是大写的P,这样避免与其他命令冲突。另外我后面加入grep过滤,实际上是多余的,主要我定义grep的彩色显示参数,这样显示效果要好一些!
$ env | grep -i grep
GREP_COLOR='01;32'
GREP_OPTIONS='--color=auto'

$ P rowsource

NAME                                DESCRIPTION                                                                            DEFAULT_VALU SESSION_VALU SYSTEM_VALUE
----------------------------------- -------------------------------------------------------------------------------------- ------------ ------------ ------------
_rowsource_execution_statistics     if TRUE, Oracle will collect rowsource statistics                                      TRUE         FALSE        FALSE
_rowsource_profiling_statistics     if TRUE, Oracle will capture active row sources in v$active_session_history            TRUE         TRUE         TRUE
_rowsource_statistics_sampfreq      frequency of rowsource statistic sampling (must be a power of 2)                       TRUE         128          128



目录
相关文章
|
2月前
|
移动开发 Shell Linux
百度搜索:蓝易云【Shell错误:/bin/bash^M: bad interpreter: No such file or directory】
将 `your_script.sh`替换为你的脚本文件名。运行此命令后,脚本文件的换行符将被转换为Linux格式,然后就可以在Linux系统上正常执行脚本了。
33 8
|
26天前
|
存储 缓存 Linux
【Shell 命令集合 磁盘维护 】Linux 设置和查看硬盘驱动器参数 hdparm命令使用教程
【Shell 命令集合 磁盘维护 】Linux 设置和查看硬盘驱动器参数 hdparm命令使用教程
35 0
|
4月前
|
Linux Shell Windows
4:Bash shell命令-步入Linux的现代方法
4:Bash shell命令-步入Linux的现代方法
53 0
|
26天前
|
编解码 Linux Shell
【Shell 命令集合 系统设置 】Linux 设置Linux系统的控制台参数和属性setconsole命令 使用指南
【Shell 命令集合 系统设置 】Linux 设置Linux系统的控制台参数和属性setconsole命令 使用指南
33 0
|
26天前
|
存储 Shell Linux
【Shell 命令集合 系统设置 】Linux 将参数作为命令行输入 eval命令 使用指南
【Shell 命令集合 系统设置 】Linux 将参数作为命令行输入 eval命令 使用指南
25 0
|
2月前
|
存储 Shell
Shell变量和参数
Shell变量和参数
16 3
|
4月前
|
Shell
Shell(如Bash)命令行技巧
Shell(如Bash)命令行技巧
25 2
|
4月前
|
Unix Shell iOS开发
Shell错误:/bin/bash^M: bad interpreter: No such file or directory
Shell错误:/bin/bash^M: bad interpreter: No such file or directory
43 0
|
4月前
|
存储 Unix Shell
Linux【脚本 04】Shell脚本传递参数的4种方式(位置参数、特殊变量、环境变量和命名参数)实例说明
Linux【脚本 04】Shell脚本传递参数的4种方式(位置参数、特殊变量、环境变量和命名参数)实例说明
167 0
|
4月前
|
Shell
在Shell(如Bash)中,`while`循环
在Shell(如Bash)中,`while`循环
41 2