Skip to main content
Version: 24.3.x

Categories: String

MASK

Returns a masked version of a string.

Syntax

MASK(expression varchar [, uc_mask varchar] [, lc_mask varchar] [, num_mask varchar]) → varchar

  • expression: The string to mask.
  • uc_mask (optional): Controls the mask character for upper case letters.
  • lc_mask (optional): Controls the mask character for lower case letters.
  • num_mask (optional): Controls the mask character for numbers.

Examples

MASK example
SELECT MASK('abcd-ABCD-1234')
-- xxxx-XXXX-nnnn
MASK example containing optional arguments.
SELECT MASK('abcd-ABCD-1234', 'U', 'u', '#')
-- uuuu-UUUU-####
MASK example containing only the optional argument for lower case letters.
SELECT MASK('abcd-ABCD-1234', '', 'u', '')
-- uuuu-XXXX-nnnn

Usage Notes

By default, upper case letters are converted to X, lower case letters are converted to x, and numbers are converted to n. You can override the characters used in the mask by supplying optional arguments. The first argument controls the mask character for upper case letters, the second argument for lower case letters, and the third argument for numbers.