How to get extent info into DBEXPORT
Posted in 1995
Greetings from Germany,
I've been meaning to look at this code
and give it a good testing, I have used it several times in an
extended format and am satisfied that it works fine. I would
like to improve it so that the indexes are at the end of the
code so as to save time in loading but for the present its
current format will have to suffice. As Jack says Enjoy...
Tom Hogarty Standard Disclaimers Apply
Siemens Nixdorf Informationsystems
Paderborn, Germany
Tel +49-52518-11602
+49-5254-65553($HOME)
e-mail <hogarty.pad@sni.de>
-- cut here-- cut here-- cut here-- cut here-- cut here-- cut here
################################################################
# name : exportx #
# from : Tom Hogarty SNI Paderborn Germany #
# usage : exportx dbname (where dbname.sql exists) #
# description : takes the dbname <.sql> as input along with #
# the output from the systables locklevel #
# first extent and next extent to produce #
# a schema with the extent/lock schema #
# #
# N.B. I have tested this code today 1.April.1995 #
# it worked fine. I would like to polish it #
# up a bit before posting but I'm sure I won't #
# find the free time. Any comments/corrections ## appreciated at hogarty.pad@sni.de #
# #
################################################################
if [ $# = 0 ]
then echo "usage: $0 <database>";
echo " # expects file '<database>.sql' from 'dbexport'"
echo " #"
echo " # creates file '<database>.sqln' with extent sizes and lock mode"
echo " # found in 'informix.systables'"
echo " #"
echo " # the script uses 'isql' or 'dbaccess'!!!!!"
exit 1
fi
isql $1 - <<EOF 1>$1.tmp1 2>>/dev/null
set isolation to dirty read;
select owner, tabname, fextsize, nextsize, locklevel
from informix.systables
where tabid > 99;EOF
if [ $? -ne 0 ]
then dbaccess $1 - <<EOF 1>$1.tmp1 2>>/dev/null
set isolation to dirty read;
select owner, tabname, fextsize, nextsize, locklevel
from informix.systables
where tabid > 99;EOF
fi
sed '/^$/d
/owner/d
s/^\\([^ ]*\\) *\\([^ ]*\\) *\\([0-9]*\\) *\\([0-9][0-9]*\\) \\([R,P]\\)/"\\1".\\2 extent size \\3 next size \\4 lock mode \\5;/
s/lock mode R;$/lock mode row;/
s/lock mode P;$/lock mode page;/' <$1.tmp1 >$1.tmp
rm $1.tmp1
awk '
BEGIN {
while( getline < "'$1.tmp'" == 1 )
ar[$1]=" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "$10;
drin=0;
}
{
if( drin )
if( $1 == ");" )
{
if(ar[tabnam] == "")
{
print $0;
}
else
{
printf(") %s\\n",ar[tabnam]);
}
drin=0;
}
else
print $0;
else
{
if( $1 == "create" && $2 == "table" )
{
drin=1;
tabnam=$3;
}
print $0;
}
}' $1.sql > $1.sqln
rm $1.tmp ;
-- cut here-- cut here-- cut here-- cut here-- cut here-- cut here-- cut here