w3resource

MySQL CRC32() function

CRC32() function

MySQL CRC32() returns the cyclic redundancy check value of a given string as a 32-bit unsigned value. It is a checksum that is commonly used for error-checking in network communications and data storage.

When the argument is NULL the result is NULL.

This function is available as of version 4.1 of MySQL.

This function is useful in -

  • CRC32 is a widely used error-checking technique. It's employed in network communications to ensure data integrity.
  • The CRC32 algorithm provides a quick and efficient way of verifying the integrity of data during transmission or storage.
  • In databases, CRC32 can be used to verify the integrity of records.
  • Storing the CRC32 value along with the record allows for quick checks to ensure the data has not been altered.
  • In scenarios where data is replicated across multiple systems, CRC32 values can be used to quickly identify discrepancies between the datasets.
  • CRC32 is computationally less expensive compared to some other cryptographic hash functions like SHA-256.
  • CRC32 can be used in security applications to detect changes or tampering in files.
  • CRC32 values are often used in storage systems like hard drives and SSDs for error detection.

Syntax:

CRC32(expression);

Argument:

Name Description
expression A string whose CRC32 value is to be retrieved.

Syntax Diagram:

MySQL CRC32() Function - Syntax Diagram

MySQL Version: 8.0


Example of MySQL CRC32() function

Code:

SELECT CRC32('string');

Explanation:

The above MySQL statement will return the given string’s cyclic redundancy check value as a 32-bit unsigned value.

Output:

mysql> SELECT CRC32('string'); 
+-----------------+
| CRC32('string') |
+-----------------+
|      2663297705 | 
+-----------------+
1 row in set (0.01 sec)

All Mathematical Functions

Previous:COT()
Next: DEGREES()



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/mysql/mathematical-functions/mysql-crc32-function.php