Created
October 19, 2023 02:03
-
-
Save Bivek/332243d78ffcefdcefdb0e00b3b0f3cb to your computer and use it in GitHub Desktop.
Get all the tables count in MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#STEP1: SET Max lenght according the need | |
SET group_concat_max_len = 40048; | |
#STEP2: Execute this to get the query that needs to be executed | |
SELECT left(tab, length(tab)-6) AS query | |
FROM ( | |
SELECT GROUP_CONCAT(tab SEPARATOR ' ') AS tab | |
FROM ( | |
SELECT CONCAT( | |
'SELECT "', | |
table_name, | |
'" AS table_name, COUNT(*) AS exact_row_count FROM `', | |
table_schema, | |
'`.`', | |
table_name, | |
'` UNION ' | |
) AS tab | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE table_schema = '<YOUR DATABASE NAME>' | |
) AS tmp1 | |
) AS tmp2 | |
#STEP3: copy the output from Step#2 and execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment