Created
April 26, 2014 21:18
-
-
Save rochefort/11331368 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| delimiter // | |
| DROP PROCEDURE IF EXISTS all_tables_count// | |
| CREATE PROCEDURE all_tables_count( | |
| IN schemaName VARCHAR(100) | |
| ) | |
| BEGIN | |
| DECLARE done INT; | |
| DECLARE _tableName VARCHAR(100); | |
| DECLARE cur CURSOR FOR | |
| select TABLE_NAME from information_schema.tables where TABLE_SCHEMA = schemaName order by TABLE_NAME; | |
| DECLARE EXIT HANDLER FOR NOT FOUND SET done = 0; | |
| SET done = 1; | |
| OPEN cur; | |
| WHILE done DO | |
| FETCH cur INTO _tableName; | |
| SET @s = CONCAT('SELECT \'', _tableName, '\', COUNT(*) FROM ', _tableName); | |
| PREPARE stmt from @s; | |
| EXECUTE stmt; | |
| DEALLOCATE PREPARE stmt; | |
| END WHILE; | |
| END | |
| // |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment