Skip to main content
added 27 characters in body
Source Link
nhahtdh
  • 56.9k
  • 15
  • 131
  • 164

This is what I do to get the actual count (no using the schema)

It's slower but more accurate.

It's a two step process at

  1. Get list of tables for your db. You can get it using

    mysql -uroot -p mydb -e "show tables"

     mysql -uroot -p mydb -e "show tables" 
  2. createCreate and assign the list of tables to the array variable in this bash script (separated by a single space just like in the code below)

    array=( table1 table2 table3 )

    for i in "${array[@]}"

    do

    echo $i

    mysql -uroot mydb -e "select count(*) from $i"

    done

     array=( table1 table2 table3 ) for i in "${array[@]}" do echo $i mysql -uroot mydb -e "select count(*) from $i" done 
  3. runRun it:

    chmod +x script.sh; ./script.sh

     chmod +x script.sh; ./script.sh 

This is what I do to get the actual count (no using the schema)

It's slower but more accurate.

It's a two step process at

  1. Get list of tables for your db. You can get it using

    mysql -uroot -p mydb -e "show tables"

  2. create and assign the list of tables to the array variable in this bash script (separated by a single space just like in the code below)

    array=( table1 table2 table3 )

    for i in "${array[@]}"

    do

    echo $i

    mysql -uroot mydb -e "select count(*) from $i"

    done

  3. run it:

    chmod +x script.sh; ./script.sh

This is what I do to get the actual count (no using the schema)

It's slower but more accurate.

It's a two step process at

  1. Get list of tables for your db. You can get it using

     mysql -uroot -p mydb -e "show tables" 
  2. Create and assign the list of tables to the array variable in this bash script (separated by a single space just like in the code below)

     array=( table1 table2 table3 ) for i in "${array[@]}" do echo $i mysql -uroot mydb -e "select count(*) from $i" done 
  3. Run it:

     chmod +x script.sh; ./script.sh 
Source Link
lsaffie
  • 1.8k
  • 1
  • 18
  • 24

This is what I do to get the actual count (no using the schema)

It's slower but more accurate.

It's a two step process at

  1. Get list of tables for your db. You can get it using

    mysql -uroot -p mydb -e "show tables"

  2. create and assign the list of tables to the array variable in this bash script (separated by a single space just like in the code below)

    array=( table1 table2 table3 )

    for i in "${array[@]}"

    do

    echo $i

    mysql -uroot mydb -e "select count(*) from $i"

    done

  3. run it:

    chmod +x script.sh; ./script.sh