Heim  >  Artikel  >  Backend-Entwicklung  >  通过php快速统计某个数据库中每张表的数据量_PHP教程

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

WBOY
WBOYOriginal
2016-07-21 15:16:29921Durchsuche

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

执行结果:


复制代码 代码如下:

$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'].'
"
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/325888.htmlTechArticle所以自己简单写了几行代码用来实现以上需求 执行结果: 复制代码 代码如下: ?php $conn=mysql_connect('localhost','root',''); mysql_select_db('数据库',...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn