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.
| Privilege | What it allows | Typical use |
|---|---|---|
| SELECT on column | Reading the column in queries | Analysts see names but not salaries |
| UPDATE on column | Changing values in that column only | Support staff edit contact details |
| INSERT on column | Supplying values when adding rows | Intake forms fill limited fields |
| REFERENCES on column | Creating foreign keys to the column | Controlled cross-table constraints |
| DENY on column | Explicit block overriding grants | SQL Server exception for one field |
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.
| Approach | How it works | Advantages | Drawbacks |
|---|---|---|---|
| Native column grants | Privileges on named columns | Enforced by engine, simple | Many grants to maintain |
| Restricted views | View exposes only allowed columns | Portable, easy to explain | Base table access must be revoked |
| Policy tags | Columns labeled, policies bound to labels | Scales across many tables | Platform-specific features |
| Masking policies | Engine returns altered values | Queries keep working | Not true access denial |
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 compared with related controls
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.
| Control | Protects against | Granularity | Data at rest |
|---|---|---|---|
| Column-level security | Unauthorized reading of fields | Column | Stored in clear |
| Row-level security | Access to other users’ records | Row | Stored in clear |
| Dynamic data masking | Casual exposure in results | Column, display only | Stored in clear |
| Column-level encryption | Theft of files or backups | Column | Encrypted |
| Transparent data encryption | Theft of storage media | Database or tablespace | Encrypted |
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.
| Situation | Recommended choice | Reason |
|---|---|---|
| Analysts must never see salaries | Column grants or views | True denial of access |
| Call center needs last four card digits | Dynamic data masking | Partial value is sufficient |
| Backups leave the data center | Column-level encryption | Protects data outside the engine |
| Same field across many tables | Tag-based policies | One rule, consistent enforcement |
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.