我个人喜欢使用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
如果要查询隐含参数,往往要切换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