On this page

    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: Controls the mask character for upper case letters.
    • lc_mask: Controls the mask character for lower case letters.
    • num_mask: 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-####
    

    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.