Mysql uses selectcount (*) fromtable_name to query the total number of records in a table. What should I do if I want to quickly know the number of records of all tables in the database? If you use mysql 5.0 or later, you can query the tables Table in the information_schema database. This table uses table_rows to record the number of rows of the table. For example
Mysql uses select count (*) from table_name to query the total number of records of a table. What should I do if I want to quickly know the number of records of all tables in the database? If you use mysql 5.0 or later, you can query the tables Table in the information_schema database. This table uses table_rows to record the number of rows of the table. For example
Mysql uses select count (*) from table_name to query the total number of records of a table. What should I do if I want to quickly know the number of records of all tables in the database? If you use mysql 5.0 or later, you can query the tables Table in the information_schema database. This table uses table_rows to record the number of rows of the table. For example, to view the number of records of all tables in the database testdb:
use information_schema;select table_name,table_rows from tableswhere TABLE_SCHEMA = 'testdb'order by table_rows desc;
However, for InnoDB tables, table_rows row counts are only approximate estimates.
Another method is to concatenate an SQL statement using the tables Table of the information_schema database, for example:
use information_schema;select concat( 'select "', TABLE_name, '", count(*) from ', TABLE_SCHEMA, '.', TABLE_name, ' union all') from tableswhere TABLE_SCHEMA='testdb';
You just need to manually process the generated results, at least faster than spelling a table.
Original article address: mysql views the number of records of all tables in the database. Thank you for sharing it with the original author.