db2系统表相应功能

SYSIBM: 基本系统编目,不建议直接访问
SYSCAT: 默认授权给Public组.只读编目视图,一般通过这个来获取编目信息
SYSSTAT: 可更新编目视图,会影响优化器的优化策略
SYSFUN: 用户定义函数
SYSPROC: 存放一组系统的存储过程

如果你需要知道具体的每个编目表所产生的作用,可以去info center里面去搜索关键字: Road map to the catalog views, 可以得到所有以syscat.开头的编目视图(一般情况下用的也是这个).当然我还自己mark了一些牛大师的书里头提到的常用的对系统编目表的SQL语句,仅供参考(飞鹏大牛的书看完了还没做笔记...他的书里面也有许多有用的SQL语句):

1. 监控缓冲池命中率:
select substr(db_name,1,8) as DB_NAME, substr(bp_name,1,8) as BP_NAME, total_hit_ratio_percent as TOTAL_HR, data_hit_ratio_percent as DATA_HR, index_hit_ratio_percent as INDEX_HR, xda_hit_ratio_percent as XDA_HR from SYSIBMADN.BP_HITRATIO where bp_name not like ‘%IBMSYSTEM%’;
2. 监控PACKAGE CACHE大小:
with dbcfg1 as (select int(value) as pckcachesz from sysibmadm.dbcfg where name  ‘pckcachesz’ ) select pckcachesz as “Package Cache Size”, pkg_cache_lookups as “Lookups”, pkg_cache_inserts as “Inserts”, pkg_cache_num_overflows as “Overflows”, 100 * pkg_cache_size_top / (pckcachesz * 4096) as “%PKG Cache alloc” from dbcfg1, sysibmadm.snapdb;
3. 监控执行成本最高的SQL语句
select AGENT_ID, ROWS_SELECTED, ROWS_READ from sysibmadm.SNAPAPPL fetch first 10 rows only;
通过对比SELECT 和READ的值来进行判断.
4. 监控运行最长的SQL语句:
select substr(appl_name,1,15) as Appl_name, elapsed_time_min as Elapsed_Min, appl_status as Status, substr(auth,1,10) as auth_id, substr(inbound_comm_address,1,15) as IP_Address, substr(stmt_text,1,30) as SQL_Statement from sysibmadm.long_running_sql order by 2 desc;
5. 监控SQL准备和预编译时间最长的SQL语句:
select num_executions, average_execution_time_s(SQL语句平均执行时间), prep_time_ms(最长的SQL预编译时间), prep_time_percent(预编译时间占整个执行时间的百分比), substr(stmt_text,1,40) as SQL_TEXT from sysibmadm.query_prep_cost where average_execution_time_s > 0 order by prep_time_percent desc;
6. 监控执行次数最多的SQL语句:
select num_executions as Num_Excus, average_execution_time_s as Avg_times_s, stmt_sorts as Num_Sorts, sorts_per_execution as Sort_per_stmt, substr(stmt_text,1,35) as SQL_stmt from sysibmadm.top_dynamic_sql where num_execution > 0 order by 1 desc fetch first 5 rows only;
7. 监控排序次数最多的SQL语句:
select STMT_SORTS, SORTS_PER_EXECUTION, substr(stmt_text,1,60) as STMT_TEXT from sysibmadm.top_dynamic_sql by STMT_SORTS desc fetch first 5 rows only;
8. 监控LOCK WAIT时间:
select substr(ai.appl_name,1,20) as appl_name, substr(ai.primary_auth_id,1,10) as auth_id, ap.lock_waits as lock_waits, ap.lock_waits_time / 1000 as Total_waits_s, ap.lock_waits_time / ap.lock_waits as Avg_waits_ms from sysibmadm.snapappl_info ai, sysibmadm.snapappl ap where ai.agent_id = ap.agent_id and ap.lock_waits > 0;
9. 监控LOCK CHAIN:
select substr(ai_h.appl_name,1,0) as Hold_App, substr(ai_h.primary_auth_id,1,10) as Holder, substr(lw.appl_name,1,10) as Wait_app, substr(lw.authid,1,10) as Waiter, lw.lock_mode, lw.lock_object_type, substr(lw.tabname,1,10) as TabName, substr(lw.tabschema,1,10) as Schema, timestampdiff(2,char(lw.snapshot_timestamp - lw.lock_wait_start_time)) as waiting_s from sysibmadm.lockwaits lw, sysibmadm.snapappl_info ai.h where lw.agent_id_holding_lk = ai_h.agent_id;
10. 监控锁内存使用:
with dbcfg1 as (select float(int(value) * 4096) as locklist from sysibmadm.dbcfg where name = ‘locklist’), dbcfg2 as (select float (int(value) ) as maxlock from sysibmadm.dbcfg where name = ‘maxlock’) select dec ((lock_list_in_use/locklist) * 100,4,1) as % Lock_List, dec((lock_list_in_use/(locklist*(maxlocks/100))*100),4,1) as %_to_Maxlock(Maxlock的配置大小是多少), appls_cur_cons as Number_of_cons, lock_list_in_use/appl_cur_cons as Avg_Lock_Mem_per_Con_bytes from dbcfg1, dbcfg2, sysibmadm.snapdb;
11. 监控锁升级,死锁和锁超时:
select substr(ai.appl_name,1,10) as Application, substr(ai.primary_auth_id,1,10) as AuthID, int(ap.locks_held) as Locks, int(ap.lock_escals) as Escalations, int(ap.lock_timeouts) as Lock_timeouts, int(ap.deadlocks) as Deadlocks, int(ap.int_deadlock_rollbacks) as Dlock_Victim, substr(inbound_comm_address,1,15) as IP_Address from sysibmadm.snapappl ap, sysibmadm.snapappl_info ai where ap.agent_id =  ai.agent_id;
12. 监控全表扫描的SQL:
select substr(authid,1,10) as authid, substr(appl_name,1,20) as appl_name, percent_rows_selected from sysibmadm.appl_performance;
13. 检查page cleaner是否足够:
wuth db_snap as (select float(pool_drty_pg_steal_clns) as pg_steal, float(pool_drty_pg_thrsh_clns) as chg_pg_thrsh, float(pool_lsn_gap_clns) as softmax, float(pool_drty_pg_steal_clns + pool_drty_pg_thrsh_cls + pool_lsn_gap_clns) as total_clns from sysibmadm.snapdb) select dec(( pg_steal/toal_clns) * 100,4,1) as %steals, dec(( chg_pg_thrsh/total_clns) * 100,4,1) as %Threshold, dec(( softmax / total_clns) * 100,4,1) as %Softmax from db_snap;
14. 监控PREFETCHER是否足够:
with bp_snap as (select substr(br_name,1,30) as bp_name, unread_prefetch_pages, pool_async_data_reads + pool_async_index_reads as async_reads, pool_data_p_reads + pool_index_p_reads + pool_temp_data_p_reads + pool_temp_index_p_reads as Total_Reads from sysibmadm.snapbp where bp_name not like ‘IBMSYSTEM%’) select bp_name, unread_prefetch_pages, dec (100 *(Total_reads * Async_reads ) / Total_reads,5,2) as %Synch_Reads, dec (100 * unread_prefetch_pages /Total_reads, 5,2) as %Unread_Pages(异步I/O服务器预存取到缓冲池没有使用的页) from bp_snap;
15. 监控数据库内存使用(未启用STMM情况下):
select pool_id, pool_secondary_id, pool_current_size, pool_watermark from sysibmadm.snapdb_memory_pool;
16. 监控日志使用情况:
select int (total_log_used/1024/1024) as Log_used_Meg, int(total_log_available/1024/1024) as Log_Space_Free_meg, int((float(total_log_used) / float(total_log_used + total_log_available)) * 100) as Pct_Used, int (tot_log_used_top/1024/1024) as Max_Log_Used_Meg, int(sec_log_used_top/1024/1024) as Max_Sec_Used_Meg(日志使用的高水位), int(sec_logs_allocated) as Secondaries from sysibmadm.snapdb;
17. 监控占用日志空间最旧的交易:
select substr(ai.appl_status,1,20) as Status, substr(ai.primary_auth_id,1,10) as Authid, substr(ai.appl_name,1,15) as Appl_name, int(ap.UOW_LOG_SPAC_USED/1024/1024) as Log_Used_MB, Int(ap.appl_idle_time/60) as Idle_for_min, ap.appl_con_time as Connected_Since from sysibmadm.snapdb db, sysibmadm.snapappl ap, sysibmadm.snapappl_info ai where ai.agent_id = db.APPL_ID_OLDEST_XACT and ap.agent_id = ai.agent_id;
18. 监控存储路径:
select substr(type,1,20) as type, substr(path,1,50) as path from sysibmadm.dbpaths order by type;
19. 监控表空间使用情况:
select substr(tbsp_name,1,18), tbsp_type, tbsp_free_size_kb, tbsp_utilization_percent from sysibmadm.tbsp_utilization;
20. 利用系统编目表写脚本:
例1: 以表名为名称大批量导出表:
select ‘export to ‘||tabname||’.ixf of ixf select * from ‘||rtrim(tabschema)||’.’||tabname||’;’ from syscat.tables where type=’T’ and tabschema not in (‘SYSIBM’, ‘SYSCAT’, ‘SYSSTAT’, ‘SYSTOOLS’)”
例2: 大批量授权:
select ‘grant select on table ‘||rtrim(tabschema)||’.’||tabname||’ to user username; ‘ from syscat.tables where type = ‘T’ and tabeschema not in (‘SYSIBM’, ‘SYSCAT’, ‘SYSSTAT’, ‘SYSTOOLS’)”

转载于:https://www.cnblogs.com/xiaojianblogs/p/6736596.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/269585.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

怎么博客圆的文章越来越杂?

最近发现怎么博客圆的文章越来越杂?PHP,JAVA等非.NET技术也来拉好象博客圆现在不是一个纯.NET社区拉管理员是不是该采取一些手段来防止这种现象的扩大

idea 快捷键获取类的全限定类名(包名+类名)

什么是全限定类名:就是 包名类名 1:选中一个类名,然后右键 Copy Reference 2:点击paste without Formatting 3:查看结果

java additem 错,Java错误:IllegalArgumentException:向容器添加窗口

我一直收到错误:Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a containerat java.awt.Container.checkNotAWindow(Container.java:483)at java.awt.Container.addImpl(Container.java:1084)at java.awt.Containe…

今天狂想自杀,找了两个星期的工具,原来我已经有了。

人爱偷懒,没办法。上网时,偶然间,发现了一个叫ReSharper的工具,这个东西的虽然支持重构,据大家的介绍,但功能不是很强,但我偶然发现里面的live template功能,可以极大地提高编程的效…

UICollectionView——整体总结

前言 这几天有时间看了下UICollectionView的东西,才发觉它真的非常强大,很有必要好好学习学习。以前虽然用过几次,但没有系统的整理总结过。这两天我为UICollectionView做一个比较全面的整理。包括基本使用,自定义布局&#xff0c…

java Class对象返回的都是指向同一个java堆地址上的Class引用

一旦类被加载了到了内存中,那么不论通过哪种方式获得该类的Class对象,它们返回的都是指向同一个java堆地址上的Class引用。jvm不会创建两个相同类型的Class对象 public class Cat {static {System.out.println("wwwww");} }class T1 {public s…

matlab基础与实例教程,MATLAB基础与实例教程

系统全面,实例丰富 考虑到Matlab进行仿真和运算分析时的基础知识和实践操作,讲解从基础的变量、函数、数据类型等入手,涉及到数学分析、图形可视化、Simulink仿真、文件读写等,全面地介绍了Matlab的分析方法。 精心编排&#xff0…

Android开发技巧——ViewPager加View情况封装PagerAdapter的实现类

ViewPager是Android的support库中的一个控件。 ViewPager Fragment的使用,已经有FragmentAdapter的实现可以帮助我们快速进行开发了; ViewPager View都要自己去继承PagerAdapter并实现,重写那些写过一次又一次的方法,于是以下对…

近300万记录的论坛还用这个分页存储过程

http://www2.gliet.edu.cn/club2/bbs/list_new_today.asp用于列出今日最新贴的。有个想不明的问题是为什么DeclareSqlText Varchar(1000)声明为1000个字符大了,但超过255字符之后exec(SqlText)就会出错。自动把后面的cut掉了?ALTERPROCEDUREbbsListNewTo…

php横排代码,20行代码原生js实现文字横向轮播

20行代码实现文字横向轮播效果1 页面布局代码恭喜793765***获得 50元超市充值卡卡奖励恭喜793765***获得 50元超市充值卡卡奖励恭喜793765***获得 50元超市充值卡卡奖励恭喜793765***获得 50元超市充值卡卡奖励恭喜793765***获得 50元超市充值卡卡奖励恭喜793765***获得 50元超…

JAVA项目中classpath路径详解

classpath是什么路径? 1.classpath指的是类路径,也就是编译之后的target文件夹下的WEB-INF/class文件夹。 2.resources文件夹存放的是各种配置文件,当项目被编译时resources下的所有配置文件均被放在 WEB-INF/class文件夹下。也就是类路径下…

将一张表的主键(ID)重置为从1开始自增排列

如果你有一张表,你的主键是ID,然后由于测来测去的原因,你的ID不是从1开始连续的自增了。 终于有一天,使用这张表的某个系统要导入正式数据了,强迫症这时候就表现的明显了,浑身不自在, 这时候你就…

涉险获胜和兵不血刃

两场比赛,两种心情。昨天的羽毛球混双决赛,除了第一局以外,中国队一直处于落后追赶的局面,让人看得心惊肉跳,手心也直冒汗。好在张军、高崚的斗志始终旺盛,互相鼓励,最终拖垮了英国选手而卫冕成…

matlab 图像的色彩强度,图像色彩增强的问题,,,小白给跪,

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼img_srcrgb2gray(img_src);img_srcdouble(img_src);[M,N]size(img_src);L256;for i1:Mfor j1;Nif img_src(i,j)R(i,j)0;G(i,j)4*img_src(i,j);B(i,j)L;elseif img_src(i,j)<L/2R(i,j)0;G(i,j)L;B(i,j)4*img_src(i,j)2*L;elseif …

Idea运行项目报错:java.lang.OutOfMemoryError: Java heap space/ java.lang.OutOfMemoryError: GC overhead 解决方法

问题 使用Idea运行代码量比较多的项目时&#xff0c;会报错&#xff1a;java.lang.OutOfMemoryError: Java heap space java.lang.OutOfMemoryError: GC overhead limit exceeded java.lang.OutOfMemoryError: GC overhead limit exceeded 仔细看了整个报错过程&#xff0c;堆…

数据库读写分离(aop方式完整实现)

http://blog.csdn.net/machunlin2010/article/details/46471983转载于:https://www.cnblogs.com/baihaojie/p/6742171.html

C#设计模式(10)-Adapter Pattern

内容篇幅较长,请点击这里阅读全文

Leaning Method

001用分布在两个地方的两台办公电脑开发一个项目&#xff0c;计划使用gitee同步代码。具体应该怎么操作&#xff1f; 要使用 Gitee 同步代码&#xff0c;你可以按照以下步骤进行操作&#xff1a; 在两台办公电脑上都安装 Git 客户端&#xff0c;并在 Gitee 上创建一个项目仓库…

wamp php文件怎么创建数据库,phpmyadmin怎么创建数据库

phpmyadmin怎么创建数据库?1、首先登陆phpmyadmin&#xff0c;有两种方法&#xff0c;第一钟是直接点击wampserver图标&#xff0c;再点击phpmyadmin即可登陆进来是最常用的方法&#xff1b;其次是在浏览器地址中输入http://localhost:8080/phpmyadmin(注意8080是端口号&#…

maven的三大生命周期

一、Maven的生命周期 Maven的生命周期就是对所有的构建过程进行抽象和统一。包含了项目的清理、初始化、编译、测试、打包、集成测试、验证、部署和站点生成等几乎所有的构建步骤。 Maven的生命周期是抽象的&#xff0c;即生命周期不做任何实际的工作&#xff0c;实际任务由插…