AdvancedINSERT, UPDATE, DELETE
Conditional aggregate UPDATE (normalize data)
The query
SQL
-- Normalize all emails to lowercase in bulk
UPDATE customers
SET email = LOWER(email)
WHERE email != LOWER(email) -- only update if needed
RETURNING cust_id, email AS normalized_email;
-- Normalize phone numbers: remove dashes and spaces
UPDATE customers
SET phone = REGEXP_REPLACE(REGEXP_REPLACE(phone, '[-\s()]', '', 'g'), '^[0+91]+', '')
WHERE phone IS NOT NULL
AND phone ~ '[-\s()]';Note
“Conditional UPDATE with WHERE ensures only matching rows are modified — faster than updating all rows.