#!./perl # # dbcount -- Emit a count of the table sizes in a given Oracle database # # Written by Clint Goss , November 1998 # BEGIN { # Access Perl modules #push (@INC, ...your lib directory here...); # Point to our preferred installation of Oracle #$ENV{'ORACLE_HOME'} = ...your Oracle Home here...); } # Perl Modules use OraConnection; # Connection to Oracle, incl DBI and DBD::Oracle use Getopt::Std; # Command-line option processing use strict; # Restrict unsafe variables, refs, barewords # Process command-line arguments and options sub usage { print <connect ($database, $username, $password); # Fetch the list of Table / View names my ($tableOrViewNames) = $dbc->tableOrViewNames (); printf "%30s %5s %7s\n", "Table", "Type", "Record Count"; printf "%30s %5s %7s\n", "-----", "----", "------------"; my ($tableOrViewName); foreach $tableOrViewName (@$tableOrViewNames) { if ($pattern) { if ($tableOrViewName !~ /$pattern/) { next; } } printf "%30s %5s %7d\n", $tableOrViewName, $dbc->tabtype ($tableOrViewName), $dbc->rowCount ($tableOrViewName); } print "\nDone: ", `date`; exit;