`
beliveAda
  • 浏览: 110516 次
  • 性别: Icon_minigender_2
  • 来自: 西安
社区版块
存档分类
最新评论

DB2数据库部分日常实用操作----Load 方法装入数据

DB2 
阅读更多
   由于最近要频繁的load数据,多多少少会遇到一些问题。而在问题出现时,不知道是什么原因导致需要解决很长时间。虽然解决了,也只是很大概的知道原因。至于其中的原理还不是很清楚。从今天开始,就将在做数据的过程中遇到的问题逐一总结一下。

1、Load 方法装入数据
   常用的方式为将数据导出到一个临时文件中,再将临时文件的内容导入到数据库中。具体操作代码如下:
    export to tempfile of del select * from TABLENAME where not 清理条件;

    load from tempfile of del modified by delprioritychar replace into TABLENAME     nonrecoverable;

说明:

在不相关的数据表export数据时,可以采取并发的形式,以提高效率;

TABLENAME指待清理table的名称;

modified by delprioritychar防止数据库记录中存在换行符,导致数据无法装入的情况;

replace into对现数据库中的内容进行替换,即将现行的数据记录清理,替换为数据文件内容;

nonrecoverable无日志方式装入;

出错时,该怎么办呢?已经找到如下方法了
在进行load的时候

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

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

SQL0668NOperation 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 查看状态,如果不是正常状态,则脱机状态进行备份即可。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics