Documentation Home
MySQL 9.5 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 41.4Mb
PDF (A4) - 41.5Mb
Man Pages (TGZ) - 272.3Kb
Man Pages (Zip) - 378.3Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


15.7.3.3 CHECKSUM TABLE Statement

CHECKSUM TABLEtbl_name [,tbl_name] ... [QUICK | EXTENDED]

CHECKSUM TABLE reports achecksum for the contents of a table. You can use this statement to verify that the contents are the same before and after a backup, rollback, or other operation that is intended to put the data back to a known state.

This statement requires theSELECT privilege for the table.

This statement is not supported for views. If you runCHECKSUM TABLE against a view, theChecksum value is alwaysNULL, and a warning is returned.

For a nonexistent table,CHECKSUM TABLE returnsNULL and generates a warning.

During the checksum operation, the table is locked with a read lock forInnoDB andMyISAM.

Performance Considerations

By default, the entire table is read row by row and the checksum is calculated. For large tables, this could take a long time, thus you would only perform this operation occasionally. This row-by-row calculation is what you get with theEXTENDED clause, withInnoDB and all other storage engines other thanMyISAM, and withMyISAM tables not created with theCHECKSUM=1 clause.

ForMyISAM tables created with theCHECKSUM=1 clause,CHECKSUM TABLE orCHECKSUM TABLE ... QUICK returns thelive table checksum that can be returned very fast. If the table does not meet all these conditions, theQUICK method returnsNULL. TheQUICK method is not supported withInnoDB tables. SeeSection 15.1.24, “CREATE TABLE Statement” for the syntax of theCHECKSUM clause.

The checksum value depends on the table row format. If the row format changes, the checksum also changes. For example, the storage format for temporal types such asTIME,DATETIME, andTIMESTAMP changed in MySQL 5.6 prior to MySQL 5.6.5, so if a 5.5 table is upgraded to MySQL 5.6, the checksum value may change.

Important

If the checksums for two tables are different, then it is almost certain that the tables are different in some way. However, because the hashing function used byCHECKSUM TABLE is not guaranteed to be collision-free, there is a slight chance that two tables which are not identical can produce the same checksum.