VeloDB Cloud
SQL Manual
Functions
string-functions
mask
mask_last_n

mask_last_n

Description

Syntax:

VARCHAR mask_last_n(VARCHAR str, [, INT n])

This function returns a masked version of str with the last n values masked. Upper case letters are converted to "X", lower case letters are converted to "x" and numbers are converted to "n". For example, the returned result of mask_last_n("1234-5678-8765-4321", 4) results in 1234-5678-8765-nnnn.

Example

// table test
+-----------+
| name      |
+-----------+
| abc123EFG |
| NULL      |
| 456AbCdEf |
+-----------+

mysql> select mask_last_n(name, 5) from test;
+------------------------+
| mask_last_n(`name`, 5) |
+------------------------+
| abc1nnXXX              |
| NULL                   |
| 456AxXxXx              |
+------------------------+

Keywords

mask_last_n