Hash Functions
This page provides a comprehensive overview of Hash functions in Databend, organized by functionality for easy reference.
Cryptographic Hash Functions
Non-Cryptographic Hash Functions
Usage Examples
Data Integrity Verification
-- Calculate MD5 hash for file content verification
SELECT
filename,
MD5(file_content) AS content_hash
FROM files
ORDER BY filename;
Data Anonymization
-- Hash sensitive data before storing or processing
SELECT
user_id,
SHA2(email, 256) AS hashed_email,
SHA2(phone_number, 256) AS hashed_phone
FROM users;
Hash-Based Partitioning
-- Use hash functions for data distribution
SELECT
XXHASH64(customer_id) % 10 AS partition_id,
COUNT(*) AS records_count
FROM orders
GROUP BY partition_id;
