WEB开发网
开发学院数据库DB2 DB2数据库日常实用操作 阅读

DB2数据库日常实用操作

 2007-11-03 14:58:09 来源:WEB开发网   
核心提示:12、Load 操作在进行load的时候db2 "load from acmmst.txt of del modified by coldel| replace into acmmst nonrecoverable ”由于数据不规范出现错误,强行中断以后,DB2数据库日常实用操作(3),进行操作的

12、Load 操作

在进行load的时候

db2 "load from acmmst.txt of del modified by coldel| replace into acmmst nonrecoverable ”

由于数据不规范出现错误,强行中断以后,进行操作的时候出现如下错误:

SQL0668N Operation not allowed for reason code "3" on table "BTP.ACMMST".

SQLSTATE=57016

此时,进行反方向操作即可:

db2 "load from /dev/null of del terminate into acmmst nonrecoverable"。

如果没有使用参数nonrecoverable,则会出现数据库状态不正确的情况,使用:

db2 list tablesapces show detail 查看状态,如果不是正常状态,则脱机状态进行备份即可。

两个表文件之间UPDATE的方法:

db2 "update cdmcrd set offset = (select cdmlsl.offset from cdmlsl where cdmlsl.crdno=cdmcrd.crdno) where cdmcrd.crdno in (select cdmlsl.crdno from cdmlsl)

13、多字段条件查询和修改:

表A中的字段有actno, cnlno,bal,pwd;表B中的字段为Actno,Cnlno,TxnAmt;目的是将A表中的bal修改为B表中的TxnAmt,命令:

db2 "update A set bal=(select txnamt from B where actno=A.actno and cnlno=A.Cnlno) where A.actno||A.cnlno in (select Actno||cnlno from B );

14、多条件匹配查询

查询某个表中条件是B?AAA的记录:

db2 "select * from A where actno like 'B_AAA%'".

查询数据中存在某些字符的记录:

db2 "select * from A where actno like '%-AAA%".

15/数据库恢复的处理

进行数据库恢复的时候使用以下的命令:

   restore db db1 to /tstdb2/catalog into db newlogpath /tstdb2/db2log buffer 2048
   replace existing redirect parallelism 16;
   set tablespace containers for 1 using (path '/tstdb2/db2tmp');
   set tablespace containers for 2 using
       (device '/dev/rtstcontlv00' 2621440, device '/dev/rtstcontlv01' 2621440,
       device '/dev/rtstcontlv02' 2621440, device '/dev/rtstcontlv03' 2621440 ) ;
   restore db db1 continue;

恢复完成以后执行命令db2s时报如下的错误:

P570:>db2s
  SQL1117N A connection to or activation of database "DB" cannot be made
  because of ROLL-FORWARD PENDING. SQLSTATE=57019
  DB21034E The command was processed as an SQL statement because it was not a
  valid Command Line Processor command. During SQL processing it returned:
  SQL1024N A database connection does not exist. SQLSTATE=08003

解决办法如下:

P570:>db2 rollforward db db to end of logs and complete
Rollforward Status
Input database alias          = db
Number of nodes have returned status  = 1
Node number              = 0
Rollforward status           = not pending
Next log file to be read        =
Log files processed          = -
Last committed transaction       = 2005-11-20-10.59.23.000000
DB20000I The ROLLFORWARD command completed successfully.

上一页  1 2 3 

Tags:DB 数据库 日常

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接