MASK
Descriptionβ
The MASK function is to shield data to protect sensitive information, and it is commonly used in data anonymization scenarios. Its default behavior is to convert a uppercase letter in the input string to X
, a lowercase letter to x
, and a number to n
.
Syntaxβ
MASK(<str> [, <upper> [, <lower> [, <number> ]]])
Parametersβ
Parameter | Description |
---|---|
<str> | String that need to be masked |
<upper> | Optional Parameter, replaces uppercase character to X by default. If a sequence of characters are input, the first character will be taken, and if non ASCII characters are input, the first byte will be taken |
<lower> | Optional Parameter, replaces lowercase character to x by default. If a sequence of characters are input, the first character will be taken, and if non ASCII characters are input, the first byte will be taken |
<number> | Optional Parameter, replaces numeric character to n by default. If a sequence of characters are input, the first character will be taken, and if non ASCII characters are input, the first byte will be taken |
Return Valueβ
Returns a string after masking uppercase character, lowercase character and lnumeric character. Special cases:
- If any Parameter is NULL, NULL will be returned.
- Non-alphabetic and non-numeric characters will do not masking
Examplesβ
select mask('abc123EFG');
+-------------------+
| mask('abc123EFG') |
+-------------------+
| xxxnnnXXX |
+-------------------+
select mask(null);
+------------+
| mask(NULL) |
+------------+
| NULL |
+------------+
select mask('abc123EFG', '*', '#', '$');
+----------------------------------+
| mask('abc123EFG', '*', '#', '$') |
+----------------------------------+
| ###$$$*** |
+----------------------------------+