Home > php教程 > php手册 > 通过php快速统计某个数据库中每张表的数据量

通过php快速统计某个数据库中每张表的数据量

WBOY
Release: 2016-06-13 11:58:14
Original
881 people have browsed it

所以自己简单写了几行代码用来实现以上需求

执行结果:


复制代码 代码如下:


$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 "






";
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 "';
}
echo "
表名 数据量
".$result_count[$v].' '.$result_count['nums'].'
"
?>
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template