Skip to content
BENIBIX Learn

Data Masking

Data🔒 Data PrivacyPersonal Data

Also known as Dynamic Data Masking, Masking Policy, Data Redaction

Showing stars in place of a private value. The real one is still kept.

Think of it like

It is like a sticker on a photo. The photo is still there, but the face is hidden.

Example

Analysts at a bank can count customers by city, but card numbers show only the last four digits. The fraud team sees them in full.

Why it matters

Many people can use one table safely. No one has to make a copy for each role.

Definition

Data masking hides private values by showing a covered version. An email might show only its first letter. A card number might show only its last four digits. With dynamic masking, the real data stays in the table. A rule checks who is asking and shows the real value only to some roles. Static masking makes a covered copy, such as for a test system.

Example code

sql
CREATE MASKING POLICY email_mask AS (val STRING)
  RETURNS STRING ->
  CASE WHEN CURRENT_ROLE() IN ('SUPPORT') THEN val
       ELSE '*****' END;

ALTER TABLE customers MODIFY COLUMN email
  SET MASKING POLICY email_mask;
A Snowflake masking rule. Support staff see the real email, and everyone else sees stars.
Masking is the second row. The real email is still in the table, just covered for this reader.

Common mistake

Masking in the dashboard only. Anyone who queries the table directly still sees the real values.

Key takeaways

  1. 1
    Covered values. Stars or part of the value.
  2. 2
    By role. Allowed roles see the real value.
  3. 3
    Dynamic or static. On read, or in a covered copy.

Compare