MySQL tutorial: STATEMENT_DIGEST [EN]
top of page
CerebroSQL

MySQL: 

STATEMENT_DIGEST

STATEMENT_DIGEST(statement)

Given an SQL statement as a string, returns the statement digest hash
value as a string in the connection character set, or NULL if the
argument is NULL. The related STATEMENT_DIGEST_TEXT() function returns
the normalized statement digest. For information about statement
digesting, see
https://dev.mysql.com/doc/refman/8.0/en/performance-schema-statement-di
gests.html.

Both functions use the MySQL parser to parse the statement. If parsing
fails, an error occurs. The error message includes the parse error only
if the statement is provided as a literal string.

The max_digest_length system variable determines the maximum number of
bytes available to these functions for computing normalized statement
digests.

URL: https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html

Example

mysql> SET @stmt = 'SELECT * FROM mytable WHERE cola = 10 AND colb = 20';
mysql> SELECT STATEMENT_DIGEST(@stmt);
+------------------------------------------------------------------+
| STATEMENT_DIGEST(@stmt) |
+------------------------------------------------------------------+
| 3bb95eeade896657c4526e74ff2a2862039d0a0fe8a9e7155b5fe492cbd78387 |
+------------------------------------------------------------------+
mysql> SELECT STATEMENT_DIGEST_TEXT(@stmt);
+----------------------------------------------------------+
| STATEMENT_DIGEST_TEXT(@stmt) |
+----------------------------------------------------------+
| SELECT * FROM `mytable` WHERE `cola` = ? AND `colb` = ? |
+----------------------------------------------------------+

bottom of page