db2命令

DB命令

一、加载数据:
1、 以默认分隔符加载,默认为“,”号
         db2 "import from btpoper.txt of del insert into btpoper"
2、 以指定分隔符“|”加载
         db2 "import from btpoper.txt of del modified by coldel| insert into btpoper"
二、卸载数据:
1、 卸载一个表中全部数据
         db2 "export to btpoper.txt of del select * from btpoper"
         db2 "export to btpoper.txt of del modified by coldel| select * from btpoper"
2、 带条件卸载一个表中数据
         db2 "export to btpoper.txt of del select * from btpoper where brhid='907020000'"
         db2 "export to cmmcode.txt of del select * from cmmcode where codtp='01'"
         db2 "export to cmmcode.txt of del modified by coldel| select * from cmmcode where codtp='01'"
三、查询数据结构及数据:
         db2 "select * from btpoper"
         db2 "select * from btpoper where brhid='907020000' and oprid='0001'"
         db2 "select oprid,oprnm,brhid,passwd from btpoper"
四、删除表中数据:
         db2 "delete from btpoper"
         db2 "delete from btpoper where brhid='907020000' or brhid='907010000'"
五、修改表中数据:
         db2 "update svmmst set prtlines=0 where brhid='907010000' and jobtp='02'"
         db2 "update svmmst set prtlines=0 where jobtp='02' or jobtp='03'"
六、联接数据库
         db2 connect to btpdbs
七、清除数据库联接
         db2 connect reset         断开数据库连接
         db2 force applications all         断开所有数据库连接
八、备份数据库
         db2move btpdbs export
         db2look -d btpdbs -e -x [-a] -o crttbl.sql
九、恢复数据库
         db2 -stvf crttbl.sql
         db2move btpdbs import
十、DB2帮助命令:
         db2 ?
         db2 ? restroe
         db2 ? sqlcode (例:db2 ? sql0803) 注:code必须为4位数,不够4位,前面补0
十一、bind命令:将应用程序与数据库作一捆绑,每次恢复数据库后,建议都要做一次bind
        (1) db2 bind br8200.bnd
        (2) /btp/bin/bndall /btp/bnd
            /btp/bin/bndall /btp/tran/bnd
十二、查看数据库参数:
           db2 get dbm cfg
           db2 get db cfg for btpdbs
十三、修改数据库参数:
           db2 update db cfg for btpdbs using LOGBUFSZ 20
           db2 update db cfg for btpdbs using LOGFILSIZ 5120
           改完后,应执行以下命令使其生效:
           db2 stop
           db2 start
补充:
        db2 set schema btp         修改当前模式为"btp"
        db2 list tablespaces show detail          查看当前数据库表空间分配状况
        db2 list tablespace containers for 2       show detail 查看tablespace id=2使用容器所在目录
        db2 list application
        db2 list db directory                    列出所有数据库
        db2 list active databases                列出所有活动的数据库
        db2 list tables for all                  列出当前数据库下所有的表
        db2 list tables for schema btp           列出当前数据库中schema为btp的表
        db2 list tablespaces show detail         显示数据库空间使用情况
        db2 list packages for all
        db2 list       applications
        db2 "force applications (353)"    
        db2 "import from tab76.ixf of ixf commitcount 5000 insert into achact
        db2 "create table achact_t like achact"
        db2 "rename table achact_t to achact"
        db2 "insert into achact_t select * from achact where txndt>=(select lstpgdt from
           acmact where actno=achact.actno)"

db2 ? command       查看命令的用法      db2     ?     sqlnnnn     查看db2的错误      db2     ? nnnn      查看书数据库的出错信息    

转自 http://hi.baidu.com/teckangping/blog/item/bf436fce2d558d3ab700c857.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值