Comments - CHECKSUM TABLE

1 year, 2 months ago hans wienerschnitzel

For those who wanted to get a checksum list of all tables of the current database:

``` SET @string = NULL; SELECT GROUP_CONCAT(CONCAT("`",table_name,"`") SEPARATOR ",") INTO @string FROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY table_name ASC; SET @string = CONCAT("CHECKSUM TABLE ", @string, " EXTENDED;"); PREPARE stmt FROM @string; EXECUTE stmt; DEALLOCATE PREPARE stmt; ```

And to save this into a file:

``` ... mysql -u username my_database_name -e ' SET @string = NULL; SELECT GROUP_CONCAT(CONCAT("`",table_name,"`") SEPARATOR ",") INTO @string FROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY table_name ASC; SET @string = CONCAT("CHECKSUM TABLE ", @string, " EXTENDED;"); PREPARE stmt FROM @string; EXECUTE stmt; DEALLOCATE PREPARE stmt; ' > path/to/my_checksum.log ```

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.