欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

通過php快速統(tǒng)計某個數(shù)據(jù)庫中每張表的數(shù)據(jù)量

 更新時間:2012年09月04日 22:21:38   作者:  
在優(yōu)化數(shù)據(jù)庫的,或者在導(dǎo)入數(shù)據(jù)的時候,知道某個數(shù)據(jù)庫中哪張數(shù)據(jù)表的數(shù)據(jù)量最多,有時候?qū)ξ覀冞€是有幫助的
所以自己簡單寫了幾行代碼用來實現(xiàn)以上需求

執(zhí)行結(jié)果:


復(fù)制代碼 代碼如下:

<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db('數(shù)據(jù)庫',$conn);
$sql="SELECT information_schema.TABLES.TABLE_NAME FROM information_schema. TABLES WHERE table_schema = '數(shù)據(jù)庫'";
$res=mysql_query($sql);
while ($result = mysql_fetch_assoc($res)) {
$tables[]=$result['TABLE_NAME'];
};
echo "<table>
<tbody>
<tr>
<td>表名</td>
<td>數(shù)據(jù)量</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>"
?>

相關(guān)文章

最新評論