ITPub博客

首页 > 数据库 > 数据库开发技术 > DB2导出模式 MBS 下的所有表

DB2导出模式 MBS 下的所有表

原创 数据库开发技术 作者:fjzcau 时间:2015-03-28 18:22:06 0 删除 编辑
#--导出模式 MBS 下的所有表 
i_dbname=MBDB1
i_schema=MBS
i_expdir=/db2data1/export 

i_time=`date +%Y%m%d%H%M`
i_schema_len=`echo ${#i_schema}` 
i_tab_file=/tmp/${i_dbname}_${i_schema}.txt

db2 connect to $i_dbname

i_tab_len=`db2 -x " select max(length(tabname)) from syscat.tables where tabschema='${i_schema}'"` 
i_tab_len=`echo $i_tab_len` 

db2 -x "select char(tabschema,${i_schema_len}) || '.' || char(tabname,$i_tab_len) 
from syscat.tables where tabschema='${i_schema}' " > $i_tab_file 

mkdir -p $i_expdir 
cd $i_expdir
for i_tab in `cat $i_tab_file`
do
  db2 "export to ${i_tab}_${i_time}.ixf of ixf 
    lobs to $i_expdir lobfile ${i_tab}_${i_time}.lob modified by lobsinfile 
    messages  ${i_tab}_${i_time}.msg 
    select * from  ${i_tab} "  
done

exit 0 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22661144/viewspace-1477100/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: DB2导出给定表
请登录后发表评论 登录
全部评论

注册时间:2011-04-03

  • 博文量
    208
  • 访问量
    547156