Updated on 2025-03-13 GMT+08:00

Dynamic Data Masking Functions

This function is an internal function.

  • creditcardmasking(col text, letter char default 'x')

    Description: Replaces the digits before the last four bits following the col string with letters.

    Parameter: Character string to be replaced or character string used for replacement

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=# select * from creditcardmasking('4511-8454-2178-6551', 'x');
      creditcardmasking
    ---------------------
     xxxx-xxxx-xxxx-6551
    (1 row)
    
  • basicemailmasking(col text, letter char default 'x')

    Description: Replaces the characters before the first at sign (@) in the col string with letters.

    Parameter: Character string to be replaced or character string used for replacement

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=# select * from basicemailmasking('Alex15@huawei.com','x');
      basicemailmasking
    -------------------
     xxxxxx@huawei.com
    (1 row)
    
  • fullemailmasking(col text, letter char default 'x')

    Description: Replaces the characters (except @) before the last period (.) in the col string with letters.

    Parameter: Character string to be replaced or character string used for replacement

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=# select * from fullemailmasking('Alex15@huawei.com','x');
    fullemailmasking
    -------------------
     xxxxxx@xxxxxx.com
    (1 row)
    
  • alldigitsmasking(col text, letter char default '0')

    Description: Replaces the digits in the col string with letters.

    Parameter: Character string to be replaced or character string used for replacement

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=# select * from  alldigitsmasking('abcdef 123456 ui 323 jsfd321 j3k2l3','0');
              alldigitsmasking
    -------------------------------------
     abcdef 000000 ui 000 jsfd000 j0k0l0
    (1 row)
    
  • shufflemasking(col text)

    Description: Sorts the characters in the col string out of order.

    Parameter: Character string to be replaced or character string used for replacement

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=#  select * from  shufflemasking('abcdef 123456 ui 323 jsfd321 j3k2l3');
               shufflemasking
    -------------------------------------
      22dc3316 3jb af4e3f135sjl ud2 k32i
    (1 row)
    
  • randommasking(col text)

    Description: Randomizes the characters in the col string.

    Parameter: Character string to be replaced or character string used for replacement

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=#  select * from  randommasking('abcdef');
     randommasking
    ---------------
     63d8dc
    (1 row)
    
  • regexpmasking(col text, reg text, replace_text text, pos INTEGER default 0, reg_len INTEGER default -1)

    Description: Replaces the col string with a regular expression.

    Parameters: Character string to be replaced, regular expression, replacement start position, and replacement length.

    Return type: text

    Example:

    1
    2
    3
    4
    5
    gaussdb=#  select * from regexpmasking('abcdef 123456 ui 323 jsfd321 j3k2l3','[\d+]','0');
                regexpmasking
    -------------------------------------
     abcdef 000000 ui 000 jsfd000 j0k0l0
    (1 row)