VeloDB Cloud
SQL Manual
Functions
string-functions
mask
mask_first_n

mask_first_n

Description

Syntax:

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

This function returns a masked version of str with the first 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_first_n("1234-5678-8765-4321", 4) will be nnnn-5678-8765-4321.

Example

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

mysql> select mask_first_n(name, 5) from test;
+-------------------------+
| mask_first_n(`name`, 5) |
+-------------------------+
| xxxnn3EFG               |
| NULL                    |
| nnnXxCdEf               |
+-------------------------+

Keywords

mask_first_n