DB2常用命令集(二)

ZDNet软件频道 时间:2008-08-27 作者: |  我要评论()
本文关键词:命令集 常用 DB2 DB2
本文总结了有关DB2的常用命令。

 28, 对一张表运行统计信息

  DB2 -v runstatson table TAB_NAMEand indexes all

  29, 查看是否对数据库执行了 RUNSTATS

  DB2 -v "select tbname, nleaf, nlevels, stats_timefrom sysibm.sysindexes"

  30, 更改缓冲池的大小

  缓冲池中,当 syscat.bufferpools 的 npages 是 -1 时,由数据库的配置参数 bufferpage 控制缓冲池的大小。

  将 npages 的值更改为 -1 的命令:

  DB2 -v connect to DB_NAME

  DB2 -v select * from syscat.bufferpools

  DB2 -v alter bufferpoolIBMDEFAULTBP size -1

  DB2 -v connect reset

  DB2 -v terminate

  更改数据库配置参数 BufferPages 的命令如下:

  DB2 -v update db cfgfor dbnameusing BUFFPAGE bigger_value

  DB2 -v terminate

  31, 查看数据库监视内容列表

  DB2 -v get monitor switches

  32, 打开某个数据库监视内容

  DB2 -v update monitor switches using bufferpoolon

  33, 获取数据库快照

  DB2 -v get snapshot for all databases > snap.out

  DB2 -v get snapshot for dbm>> snap.out

  DB2 -v get snapshot for all bufferpools>> snap.out

  DB2 -v terminate

  34, 重置数据库快照

  DB2 -v reset monitor all

  35, 计算缓冲池命中率

  理想情况下缓冲池命中率在 95% 以上,计算公式如下:

  (1 -((buffer pool data physical reads + buffer pool index physical reads) /

  (buffer pool data logical reads + pool index logical reads))) *100%

  36, 创建 DB2 实例

  DB2icrt < 实例名称 >

  37, 删除 DB2 实例

  DB2idrop < 实例名称 >

  38, 设置当前 DB2 实例

  set DB2intance=DB2

  39, 显示 DB2 拥有的实例

  DB2ilist

  40, 恢复离线增量备份数据库的命令

  DB2 RESTORE DATABASE YNDC INCREMENTAL AUTOMATIC FROM D:backupautobakDB2 TAKEN AT 20060314232015

  41, 创建样本数据库

  在 unix 平台,使用: sqllib/bin/DB2sampl

  在 windows,os/2 平台,使用: DB2sampl e,e 是可选参数,指定将创建数据库的驱动器;

  42, 列出数据库中所有的表

  DB2 list tables

  43, 列出某个表的数据结构

  DB2 describe table v_ro_role

  44, 给表增加列

  ALTER TABLE STAFF ADD COLUMN PNHONE VARCHAR(20)

  45, 数据迁移方法 1

  export 脚本示例

  DB2 connect to testdb user test password test

  DB2 "export to aa1.ixf of ixf select * from table1"

  DB2 "export to aa2.ixf of ixf select * from table2"

  DB2 connect reset

  import 脚本示例

  DB2 connect to testdb user test password test

  DB2 "load from aa1.ixf of ixf replace into table1 COPY NO without prompting "

  DB2 "load from aa2.ixf of ixf replace into table2 COPY NO without prompting "

  DB2 connect reset v


百度大联盟认证黄金会员Copyright© 1997- CNET Networks 版权所有。 ZDNet 是CNET Networks公司注册服务商标。
中华人民共和国电信与信息服务业务经营许可证编号:京ICP证010391号 京ICP备09041801号-159
京公网安备:1101082134