db2数据库常用的一些实用命令

来源:互联网 发布:游戏编程只会算法 编辑:程序博客网 时间:2024/06/06 10:38

请尊重原创!

1、查看某个表状态:

db2 load query table db.tbXXX

2、查看数据库中用户表的字段数top 10

db2"select tabname, colcount, status FROM syscat.tables  WHERE tabschema NOT LIKE 'SYS%' ORDERBY colcount desc fetch first 10 rows only"

3、数据库SQL语句执行成本

db2advis -d XXXX -s "SQL语句"

4、查看执行成本视图

db2expln -d XXXX -q "SQL语句" -g  -t

5、查看表空间

db2 list tablespaces show detail

6、查看某个表空间(比如ID=5)的容器

db2 list tablespace containers for5 show detail

7、扩充某个表空间命令:实际就是扩充容器----当然扩容前先扩lv才行

db2 alter tablespace myspace extend (device '/dev/XXXlv'  1G, device '/dev/XXXXlv'  1G)   这里两个容器,每个各扩充1G容量

8、表空间增加容器

db2 alter tablespace myspace add (device '/dev/XXXXXlv'  2G)

9、查看哪个用户的SQL占用CPU高

db2pd -edus interval=5 top=10

10、根据上例中的edu_id也就是agent_id 找到对应的app_id

db2pd -db XXXX -agent |grep edu_id

11、根据上例中的app_id找到相应的SQL语句

db2pd -db XXXX -apinfo app_id

原创粉丝点击