In enterprise software engineering, direct application access to raw physical database tables is an architectural anti-pattern. Tables store confidential personal identifiable information (PII), proprietary financial margins, password hashes, and audit timestamps that frontend applications or third-party business intelligence tools should never touch.
By utilizing Views as an Abstraction and Security Barrier, database administrators achieve two primary goals:
1
Principle of Least Privilege (Security): Exposing only sanitised subsets of data.
2
Schema Decoupling (Abstraction): Allowing DBA teams to refactor, partition, or normalize physical storage tables without breaking client applications.
Row-Level and Column-Level Security
Views provide precise control over horizontal (rows) and vertical (columns) visibility.
1-- Base table containing sensitive employee information
DEFINER (Default): The view queries data using the database permissions of the user who created the view. This allows unprivileged callers to query the view even if they lack access to the base tables!
2
INVOKER: The view executes using the database permissions of the user querying the view. If the calling user lacks SELECT on the underlying base tables, query execution fails.
For strict data masking abstractions, SQL SECURITY DEFINER is standard practice: the DBA (Definer) creates the view, and users (Invokers) are granted access exclusively to the view.
Interactive Quiz• Knowledge Check
Multiple Choice Questions
Question 1
What is the primary purpose of using SQL views as an abstraction layer?
Question 2
What does SQL SECURITY DEFINER indicate on a view?
Question 3
Under SQL SECURITY INVOKER, what happens if the querying user has SELECT on the view but NOT on the underlying base table?
Question 4
How can a view satisfy GDPR data locality compliance for regional analysts?
Question 5
Why is exposing base tables directly to third-party reporting tools considered bad practice?
Next Lesson
Non-Recursive CTEs with WITH Clause
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.