|
執行結果:

復制代碼 代碼如下:
<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db('數據庫',$conn);
$sql="SELECT information_schema.TABLES.TABLE_NAME FROM information_schema. TABLES WHERE table_schema = '數據庫'";
$res=mysql_query($sql);
while ($result = mysql_fetch_assoc($res)) {
$tables[]=$result['TABLE_NAME'];
};
echo "<table>
<tbody>
<tr>
<td>表名</td>
<td>數據量</td>
</tr>";
foreach ($tables as $k=>$v){
$sql_count="select count(id) AS nums,'".$v."' from ".$tables[$k];
$res_count=mysql_query($sql_count);
$result_count = mysql_fetch_assoc($res_count);
echo "<tr><td>".$result_count[$v].'</td><td>'.$result_count['nums'].'</td></tr>';
}
echo "</tbody></table>"
?>
php技術:通過php快速統計某個數據庫中每張表的數據量,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。