MySQL-CommandsQueries

From DevRandom

Jump to: navigation, search

Sum of all index and data length in a database.


mysql DBNAME -e "show table status like '%'\G;" |egrep 'Index_length|Data_length' \
 |awk -F: '{gsub (/ */, "", $2) ; tot += $2; } END {print "Total= " tot}'

Do the same with all databases

for d in `mysql -e "show databases\G" | grep "Database" |awk '{ gsub (/ */, "", $2) ; print $2}'`; do echo -n  $d  ;\
 mysql $d -e "show table status like '%'\G;" |egrep 'Index_length|Data_length' | \
awk -F: '{gsub (/ */, "", $2) ; tot += $2; } END {print "= " tot}' ; done
Views
Personal tools
About Me

Blog

Contact Me

Resume

Photos