dbload 유틸리티를 사용할때 필요한 command file을 생성하여 주는 스크립트입니다. 해당 데이타베이스에 있는 모든 테이블에 대하여 만들어 줍니다. 또, dbexport 로 받은 데이타를 로드할때도 사용할수 있어요. (dbloadcmd.sh, dbloadcmd2.sh 두개의 파일이 있습니다.)
dbloadcmd.sh
========================
#!/bin/sh
#name: dbloadcmd.sh
#desc: Generates dbload cmd file for all tables in Database
#parameters: database name
#default u/load file name is the same as table name ( ex, tabname.unl )
#default delimiter is "|"
#pls run this output in directory of backed-up
if [ $# -gt 0 ] ; then
db=$1
else
echo Usage: dbloadcmd.sh database
exit 1
fi
dbaccess $db 2>/dev/null <<EOT!!! | awk '
BEGIN { first = 1 }
/^$/ { next }
{ tbl = $1;
colno=$2;
printf("file %s.unl delimiter "|" %s ; insert into %s;\n",tbl,colno,tbl);
next;
}
'
output to pipe cat without headings
select distinct tabname, ncols
from systables
where systables.tabid > 99
and systables.tabtype = "T"
EOT!!!
dbloadcmd2.sh
====================
#!/bin/sh
#name: dbloadcmd.sh
#desc: Generates dbload cmd file for all tables in Database
#parameters: database name
#default u/load file name is the same as table name ( ex, tabname.unl )
#default delimiter is "|"
#pls run this output in directory of backed-up
if [ $# -gt 0 ] ; then
db=$1
else
echo Usage: dbloadcmd.sh database
exit 1
fi
dbaccess $db 2>/dev/null <<EOT!!! | awk '
BEGIN { first = 1 }
/^$/ { next }
{ tbl = $1;
colno=$2;
tabid=$3;
printf("file %5.5s%5.5d.unl delimiter "|" %s ; insert into %s;\n",tbl,tabid,colno,tbl);
next;
}
'
output to pipe cat without headings
select distinct tabname, ncols, tabid
from systables
where systables.tabid > 99
and systables.tabtype = "T"
EOT!!!
|