List:General Discussion« Previous MessageNext Message »
From:MarisRuskulis Date:July 11 2008 9:12am
Subject:Re: Count total number of records in db
View as plain text  
Warren Windvogel wrote:
> Hi,
>
> Can anyone tell me how to check the total number of records in a
> database in MySQL version 4.0
> Googling doesn't seem to help and all previous posts assume version 5.*
>
> Regards
> Warren
>
for table you can use:
SELECT COUNT(*) from the_table_name;
in whole database you can iterate trough all tables, for that create
simple bash script. For example:

#!/bin/bash

tables=`mysql -uUser -pPass -hHost database_name --skip-column-names -e
"SHOW TABLES"`
total=0
for table in $tables
do
    rows=`mysql -uUser -pPass -hHost database_name --skip-column-names
-e "SELECT COUNT(*) from $table"`
    total=$(($total+rows))
done
echo $total

Thread
Count total number of records in db Warren Windvogel11 Jul
  • Re: Count total number of records in dbMarisRuskulis11 Jul
    • Re: Count total number of records in dbDimitre Radoulov11 Jul
      • Re: Count total number of records in dbWarren Windvogel11 Jul
        • Re: Count total number of records in dbRob Wultsch12 Jul