Loads a list of existing oracle tables and their block size to a hash. Ask user for a table, lookup block from the hash, convert block to mb.
#
use Win32::ODBC;
#
# Load a list of Existing Tables and their Block size to a Hash
#
#
$TableList = new Win32::ODBC("DSN=databasename; UID=yourlogonid; PWD=y
+ourpassword;");
$TableList->Sql("select TABLE_NAME, BLOCKS from USER_TABLES where tabl
+e_name like 'PS_%'");
while ( $TableList->FetchRow() )
{
%hash= $TableList->DataHash();
$tabnam = $hash{TABLE_NAME};
$blocks = $hash{BLOCKS};
$TabNam{$tabnam} = $tabnam;
$Blocks{$tabnam} = $blocks;
$errcd = $TableList->Error();
# print "$tabnam", "\n", "$errcd";
};
$TableList->Close();
foreach $key (keys %TabNam) { print "given $key we get $Blocks{$key}\n
+"};
#
#
#
print "please enter table name\n";
$tabnam = <STDIN>;
chomp $tabnam;
#
#
$tnam = $TabNam{$tabnam}; #lookup _ta
+ble
if (!$tnam)
{
#table doesnt exist
}
else
{
#get table blocks
$Blks = $Blocks{$tnam};
$mbyte = (($Blks * 8192)/1048576);
($mb, $dummy) = split(/\./,(($mbyte)));
if ($mb < 1) {$mb = 1;}
print "TableName: $tnam Blocks: $Blks MB: $mb";
}
#
#