MASK_EMAIL()
MASK_EMAIL() — Masks the local part of an email address.
Synopsis
MASK_EMAIL( string-expression [, mask-character [, leading-characters [, trailing-characters]]] )
Description
The MASK_EMAIL() function returns the specified email, given as a string expression, with all but the first
leading-characters and last trailing-characters characters of the
local part (frequently a username) replaced by the character mask-character while preserving the
domain. For instance, the output of MASK_EMAIL('sampleuser@example.com', 'x', 2, 1) is the string
'saxxxxxxxr@example.com', where the domain is unchanged. The default values for the optional arguments
mask-character, leading-characters, and
trailing-characters are *, 1, and 0, respectively.
Example
The following example anonymizes the results of a SELECT expression by using the MASK_EMAIL() function to mask all but the first character of the local part of each email address.
SELECT first_name, last_name, MASK_EMAIL(email), city, state FROM contestants ORDER BY last_name ASC, first_name ASC;
Documentation