Column-level security

On this page 7

Column-level security is a database security control that restricts access to individual columns of a table or view, so that a user or role can query some fields of a row while being denied others. In database security, it protects sensitive attributes such as salaries, national identifiers, card numbers or medical codes without splitting the data into separate tables.

It is enforced by the database engine itself through privileges granted on specific columns, which means the rule applies to every application, report and ad hoc query that touches the table. It complements row-level security, which filters records, and column-level encryption, which protects stored values cryptographically.

How column-level security is enforced

Column-level security works by attaching privileges to named columns instead of whole tables. When a query arrives, the engine checks the column list of every referenced table during query compilation; if the statement reads or writes a column for which the user lacks permission, the whole statement fails with a permission error rather than returning partial data.

In SQL databases the mechanism is part of the standard GRANT and REVOKE syntax. A statement such as GRANT SELECT (employee_id, name, department) ON employees TO hr_viewer allows that role to read three columns while the salary column stays hidden. PostgreSQL, SQL Server, Oracle, MySQL and most cloud data warehouses support column privileges for SELECT, UPDATE, INSERT and REFERENCES.

The table below summarizes the column privileges and what each one controls.

PrivilegeWhat it allowsTypical use
SELECT on columnReading the column in queriesAnalysts see names but not salaries
UPDATE on columnChanging values in that column onlySupport staff edit contact details
INSERT on columnSupplying values when adding rowsIntake forms fill limited fields
REFERENCES on columnCreating foreign keys to the columnControlled cross-table constraints
DENY on columnExplicit block overriding grantsSQL Server exception for one field
Column privileges and their effect

Implementation approaches across platforms

Database platforms implement column-level security in several ways, and the choice affects both administration effort and query behavior. Native column grants are the most direct option, but views and policy-based tools are common when rules depend on context.

The following table compares the main approaches.

ApproachHow it worksAdvantagesDrawbacks
Native column grantsPrivileges on named columnsEnforced by engine, simpleMany grants to maintain
Restricted viewsView exposes only allowed columnsPortable, easy to explainBase table access must be revoked
Policy tagsColumns labeled, policies bound to labelsScales across many tablesPlatform-specific features
Masking policiesEngine returns altered valuesQueries keep workingNot true access denial
Ways to implement column restrictions

Cloud warehouses increasingly rely on tag-based governance: an administrator labels a column as personal data once, and a central policy decides which roles may read it. This keeps rules consistent when the same attribute, such as an email address, appears in dozens of tables.

Column-level security answers the question which attributes a user may see, whereas other controls in the same area answer different questions. Combining them is normal practice, and confusing them is a common source of gaps.

This comparison clarifies how the control relates to neighboring techniques.

ControlProtects againstGranularityData at rest
Column-level securityUnauthorized reading of fieldsColumnStored in clear
Row-level securityAccess to other users’ recordsRowStored in clear
Dynamic data maskingCasual exposure in resultsColumn, display onlyStored in clear
Column-level encryptionTheft of files or backupsColumnEncrypted
Transparent data encryptionTheft of storage mediaDatabase or tablespaceEncrypted
Comparison with neighboring controls

The essential distinction is that column-level security is an authorization control, not encryption. A database administrator with full privileges, or an attacker who obtains the data files, can still read the protected values, so regulated data usually needs encryption in addition to column restrictions.

Designing column restrictions in practice

Effective column-level security starts with data classification: each column is labeled by sensitivity before any grant is written. Privileges are then assigned to database roles, never directly to individual accounts, so that onboarding and offboarding change role membership rather than dozens of column grants.

  • Apply the principle of least privilege and grant only the columns each role needs.
  • Avoid SELECT * in applications, because a query that names a restricted column fails entirely.
  • Document which roles may read each sensitive column and review the list regularly.
  • Log access attempts through database audit to detect repeated permission failures.

The decision table below shows how common situations map to an appropriate technique.

SituationRecommended choiceReason
Analysts must never see salariesColumn grants or viewsTrue denial of access
Call center needs last four card digitsDynamic data maskingPartial value is sufficient
Backups leave the data centerColumn-level encryptionProtects data outside the engine
Same field across many tablesTag-based policiesOne rule, consistent enforcement
Choosing a column protection technique

Limitations and common mistakes

Column-level security has known blind spots that practitioners must address. The most serious is inference through other paths: a user denied the salary column may still derive it from an unrestricted view, an aggregate table, a materialized copy or a log table that was never secured.

Other frequent mistakes include granting table-level SELECT that silently overrides column restrictions, forgetting that ownership and superuser roles bypass privileges, and exporting data to analytics tools where the restriction no longer applies. Restrictions in a source database also do not travel with replicated or extracted data, so every downstream copy needs its own controls.

Finally, column restrictions can break applications that rely on wildcard queries or generic object mappers, which is why teams should test permission changes in a staging environment before applying them in production.

Understanding it simply

Column-level security works like a form with some boxes covered up. Everyone may look at the same record, but certain people cannot see specific fields, such as pay or a passport number.

The database itself checks who is asking before it shows anything, so the rule holds no matter which app is used. The key point is that it controls who may see a field, while the data itself is still stored in readable form unless it is also encrypted.

Applied in practice

A hospital keeps a single patients table with columns for name, ward, admission date, diagnosis code and insurance number. Ward clerks need names and bed assignments, billing staff need insurance numbers, and clinicians need diagnoses. The database team creates three roles and grants each one SELECT on only the required columns, then revokes table-level access from the reporting account used by the general dashboard.

After the change, a clerk who runs a query that includes the diagnosis column receives a permission error, and the attempt is recorded by the audit log. The billing extract is rebuilt to name its columns explicitly instead of using a wildcard. Because the insurance numbers are also copied to nightly backups, the team adds column-level encryption for that field. The outcome is a single shared table that meets privacy requirements without separate copies for each department.