Definição
Geram um hash a partir de um ou mais valores. Usados em chaves substitutas e para detectar mudança de linha.
MD5 e SHA2: PostgreSQL (MD5), MySQL, Snowflake, Databricks. Oracle: STANDARD_HASH(x, 'SHA256'). SQL Server: HASHBYTES. BigQuery: TO_HEX(SHA256(x)).
Exemplos
1. Chave substituta por hash
SELECT MD5(CONCAT_WS('|', store_id, product_id)) AS hk_inventory
FROM stg_inventory;2. Hash da linha para detectar mudança
SELECT customer_id,
SHA2(CONCAT_WS('|', name, email, city), 256) AS row_hash
FROM stg_customers;3. Oracle
SELECT STANDARD_HASH(name || '|' || email, 'SHA256') AS row_hash FROM stg_customers;