Rumah >pembangunan bahagian belakang >tutorial php >懂PHP和MYSQL的请进 ---------请教统计数量
原始效果
--------------------------------------------------
数据库总量:
490766329
数据库大小:
25115924452
---------------------------------------------------
要达到的效果
数据库总量:
4.90亿条
数据库大小:
23.39 GB
关键代码
$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(*)']);
}
}
?>
只会用笨办法了;
$a = 490766329;$b = 25115924452;echo number_format(floor($a*pow(10, -6))*pow(10, -2),2);echo number_format($b/pow(1024,3),2).'GB';
$sql = "select sum(TABLE_ROWS) as 记录数, sum(DATA_LENGTH+INDEX_LENGTH) as 占用空间 from information_schema.tables where table_schema='data'";$rs = mysql_query($sql);print_r(mysql_fetch_assoc($rs));