Thursday 17 February 2022

Count Actual Rows of Every Tables (MySQL)

On root database run, 1st change to your_db_name: SELECT CONCAT('SELECT ''',table_name,''', COUNT(*) FROM ', table_name, ' union all') FROM information_schema.tables WHERE table_schema = 'your_db_name'; Then connect to your database and remove the last 'union all' and add ';' then run sql e.g. MariaDB > use db_dev_01; MariaDB [db_dev_01]> SELECT 'APPLICATIONS', COUNT(*) FROM APPLICATIONS union all -> SELECT 'ATTRIBUTE', COUNT(*) FROM ATTRIBUTE union all .... .... .... -> SELECT 'ZBS_LOG', COUNT(*) FROM ZBS_LOG;

No comments: