Use php to quickly count the data volume of each table in a database. So I simply wrote several lines of code to achieve the above requirements: Copy the code as follows :? Php $ connmysql_connect (localhost, root,); mysql_select_db (database, so I wrote a few lines of code to achieve the above requirements
Execution result:
The code is as follows:
$ Conn = mysql_connect ('localhost', 'root ','');
Mysql_select_db ('database', $ conn );
$ SQL = "SELECT information_schema.TABLES.TABLE_NAME FROM information_schema. TABLES WHERE table_schema = 'database '";
$ Res = mysql_query ($ SQL );
While ($ result = mysql_fetch_assoc ($ res )){
$ Tables [] = $ result ['Table _ name'];
};
Echo"
| Table name |
Data volume |
";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"
| ". $ Result_count [$ v].' |
'. $ Result_count ['nums'].' |
';}Echo"
"
?>
Explain execution result: the code is as follows :? Php $ conn = mysql_connect ('localhost', 'root', ''); mysql_select_db ('database ',...