Original effect
--------------------------------------------------
Total database:
490766329
Database size:
25115924452
---------------------------------------------------
The effect to be achieved
Total database:
490 million article
Database size:
23.39 GB
Key code
$e = 0;
$count =mysql_query ("Select table_name from information_schema.tables where table_schema= ' data '");
while ($rows =mysql_fetch_array ($count)) {
$c = $rows [' table_name '];
$count _table=mysql_query ("SELECT count (*) from $c");
while (@ $d =mysql_fetch_array ($count _table)) {
$e = $e + ($d [' Count (*) ']);
}
}
?>
Total database:
Billions of bars
Occupied space:
23.39GB
The back of the GB is undefined please help to get down thank you
Reference Code http://www.douban.com/note/139003240/
Reply to discussion (solution)
will only use the stupid method;
$a = 490766329; $b = 25115924452;echo Number_format (Floor ($a *pow (6)) *pow (2), 2); Echo Number_format ($b/pow ( 1024,3), 2). ' GB ';
$sql = "Select sum (table_rows) as Record count, sum (data_length+index_length) as occupies space from Information_schema.tables where TABLE_SC Hema= ' data ', $rs = mysql_query ($sql);p Rint_r (Mysql_fetch_assoc ($rs));