Data masking returns a modified value (a***@example.com, ****4242) instead of the real one to whoever should not see it. In PostgreSQL, MySQL and MariaDB you can do it with views and column privileges, an extension or a proxy; the right choice depends on who reads the data and whether you can change the application.
What data masking is
Data masking replaces a sensitive value with a realistic but harmless one. The column keeps its name and the query keeps working; only the value changes.
- Static masking rewrites the stored data, usually in a copy (a staging database, a dump for developers). The original values are gone from that copy.
- Dynamic masking leaves the data as it is and masks the value when a given role or client reads it. Others still see the real value.
| Technique | What it protects | Who still sees the value |
|---|---|---|
| Masking | Values in query results | The roles or clients that are not masked |
| Encryption | Data at rest or in transit | Anyone who queries with a role that can read the column |
| Row-level security | Which rows a role sees | The full row, every column, for the rows it does see |
| Column privileges | Whether a role can read a column at all | Roles with the privilege see the real value; others get an error |
When you need it
- Personal and payment data (PII): emails, phone numbers, card numbers, national IDs.
- Compliance work: frameworks such as GDPR or PCI DSS ask you to limit who sees personal or card data. Masking is one control among several; it does not make a system compliant on its own.
- Analysts and support who need the rows but not the full values.
- Developers who work on a copy of production.
- AI agents.
SELECT email, card_number FROM customersis harmless to the database and still puts personal and payment data into an LLM's context. An agent that writes its own SQL reads whatever its role allows.
Native options per engine
| Engine | Native options | Guide |
|---|---|---|
| PostgreSQL | Views with column privileges; the postgresql_anonymizer extension (dynamic and static masking, anonymized dumps); row-level security filters rows, not columns | PostgreSQL data masking |
| MySQL | MySQL Enterprise Data Masking functions (Enterprise Edition only); views with column privileges; generated columns | MySQL data masking |
| MariaDB | The MaxScale masking filter (a separate product with its own licence); views with column privileges; generated columns | MariaDB data masking |
Every guide has SQL that was run in a container, with its real output, and says which statements come only from the docs.
Native options vs. masking at a proxy
| Views and column privileges | Masking extension or filter | Vericto proxy | |
|---|---|---|---|
| Application changes | Queries must use the view | None for the masked role or service | Point the connection at the proxy; the SQL does not change |
| Per-agent policies | One database role per agent | Per role or per account | Per database registered in Vericto: a dedicated proxy for the agent path |
| Audit | Database logs | Database or proxy logs | Each masked, blocked or flagged read is an audit trail event, with the column that triggered it |
| Performance | The view's expressions run in the database | Depends on the product | One extra hop, and the masking expressions run in the database; measured latency and method |
| Licensing | Part of the database | Depends on the product (see each guide) | Proxy and engine are AGPL-3.0-only |
They combine well: column privileges and views in the database, and the proxy on the path an agent or an untrusted client uses.
Mask columns with Vericto
Vericto masks at the proxy, for agents and applications, without changing the database or the application. You tag the column once; the proxy rewrites each query that reads it.
- Tag columns per database in the Vericto dashboard, each with a policy:
block(the query is blocked),flag(it runs and is recorded, with an alert) ormask(the projection is rewritten), and formaska style:full,last4,emailorhash. - Every read of a tagged column is reported as VERICTO-085. When a query reads several tagged columns, the strictest policy wins:
block>mask>flag. - Vericto decides on the AST of the query, by column name. It never reads the results and does not look at the values.
This is the real rewrite the engine produced for a PostgreSQL query, with email tagged mask/email and card_number tagged mask/last4:
-- The query the agent or the app sends (PostgreSQL):
SELECT id, name, email, card_number FROM customers WHERE id = 42
-- FLAGGED VERICTO-085: SensitiveColumn > customers.card_number, customers.email (mask)
-- The query the proxy forwards instead (rewritten_query):
SELECT id, name, regexp_replace(email::text, '^(.)[^@]*(@.*)?$', E'\\1***\\2') AS email, CASE WHEN char_length(card_number::text) <= 8 THEN '[redacted]'::text ELSE '****' || "right"(card_number::text, 4) END AS card_number FROM customers WHERE id = 42Real output: vericto-engine 5.0.0, evaluate() on PostgreSQL with customers.email (mask, email), customers.card_number (mask, last4) and customers.ssn (block), 2026-11-14.
And the rows that rewrite returns on PostgreSQL:
-- The rows the masked rewrite returns:
id | name | email | card_number
----+------+------------------+-------------
42 | Ana | a***@example.com | ****4242
(1 row)Tested on PostgreSQL 17.11 and 18.6 (Docker images postgres:17 and postgres:18), 2026-11-16.
Sensitive columns are configured in a Vericto workspace; the masking page lists where the feature is available. vericto-proxy mcp applies masks only when it is linked to a workspace: its local mode, with no account, has none. The details per engine are in the PostgreSQL, MySQL and MariaDB guides.
Frequently asked questions
Sources
The official documentation this guide cites, checked on 2026-11-14:
- PostgreSQL docs: rules and privileges (views)
- PostgreSQL Anonymizer documentation
- vericto-proxy 5.0.1: docs/SENSITIVE_COLUMNS.md
- Vericto docs: sensitive columns
- vericto-engine 5.0.0 (source and README)
Related pages
- PostgreSQL data masking: views, the anon extension, RLS and a proxy
- MySQL data masking: Enterprise functions, views, generated columns and a proxy
- MariaDB data masking: the MaxScale filter, views and a proxy
- How to connect AI agents to databases: 5 ways, step by step
- Vericto data masking
- Docs: sensitive columns
- Docs: agent access