I'm migrating a database recently and want to compare whether the data volume before and after migration is consistent to avoid missing data.
sql:
SELECT
table_name,
table_rows
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "你的数据库名称"
ORDER BY
table_rows DESC;
Just found a test library
If you want to count the total amount of data in the entire database, you can also
SELECT
sum(table_rows)
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "你的数据库名称"
ORDER BY
table_rows DESC;
In fact, these data are all in the metadata database that comes with mysql.
Each mysql has its own information_schema library, which records all information about the mysql service, including which tables, indexes, etc.
The information we just needed is in the TABLES table
Laughing to death, you don’t need to read the above. After working on it for a long time, the data is not accurate. After reading the MySQL document, the schema library of innodb is just an estimate. 嘤嘤嘤~