现在的位置: 首页 > 综合 > 正文

db2&unix使用总结(八)

2017年11月15日 ⁄ 综合 ⁄ 共 1233字 ⁄ 字号 评论关闭

 

1.      Db2batch, 能够提供从准备到查询完成中各个阶段所花费地具体时间,CPU 时间,以及返回的记录,用法:

db2batch -d zjbi2  -i complete-f 2.sql  -r 2.out

2.      几个有用但可能不常用的函数:

locate('3','12145367')  查找第一次出现的位置

days(date('2001-06-05'))-days(date('2001-04-05'))   相差天数

dayofweek('2011-07-07') 该周的第几天

3.      查看表被哪些存储过程引用:

select PROCNAME from SYSCAT.PROCEDURES where SPECIFICNAME in(selectdname from sysibm.sysdependencies where bname in ( select PKGNAME  from syscat.packagedep wherebname='TB_BRANCH'))

 

查看存储过程使用了那些表:

select bnamefrom syscat.packagedep where btype='T' and pkgname in(select bname fromsysibm.sysdependencies where dname in (select specificname fromsyscat.procedures where procname='PR_CLEAR_MATCH_DIVIDE_SHA'))

 

查看存储过程的ID:

select * fromsyscat.packages a,syscat.procedures b wheresubstr(b.implementation,1,8)=a.pkgname and procname=''with ur

 

查看存储过程执行计划:db2expln -c kstar -dzjbi2 -o test.out -p P2806220 -s 0

-p是存储过程id。

4.   type1索引转type2:

db2 reorgindexes all for table oracle.t1 convert

DB2_EVALUNCOMMITTED:执行前跳过谓词判断,不符合的不加锁

DB2_SKIPDELETED:忽略未提交的delete

DB2_SKIPINSERTED:忽略未提交的insert

5.  stty–a  查看终端设置属性

6.  db2 get authorizations 查看当前用户权限

7.  db2 restore db test from xxxx taken at xxxxxxxxx logtartget d:\xxxx 

db2 rollforward db test to end of logs and stop overflow log path("抽取的日志路径")

8.   强制表走索引扫描,无论统计信息如何:

Alter table tablenamevolatile cardinality。

抱歉!评论已关闭.