Virtual Private Database (VPD): Predicate-Based Database Security
The correct answer is (iv) Virtual Private Database (VPD).
A Virtual Private Database allows a system administrator to associate a security-policy function with a table, view, or synonym—collectively, a protected database relation. The function returns a predicate that Oracle Database adds to queries accessing that relation.
For example, a policy function might return:
1department_id = 10
If a user submits:
1SELECT employee_id, salary 2FROM employees;
Oracle can internally enforce the equivalent of:
1SELECT employee_id, salary 2FROM employees 3WHERE department_id = 10;
The user’s original SQL does not need to contain the security condition, and the restriction is enforced inside the database engine.
Footnotes
-
Restricting Data Access Using the Virtual Private Database - Oracle overview of VPD policy functions and predicates. ↩
-
Using Oracle Virtual Private Database to Control Data Access - Oracle Database Security Guide explanation of dynamic SQL modification. ↩
Correct Answer
Virtual Private Database (VPD) is the option that associates a function with a relation and uses the function’s returned predicate to restrict queries.
1. What the Question Is Testing
The question describes four important components:
| Clue | Meaning |
|---|---|
| “Associate a function with a relation” | Attach a security-policy function to a table, view, or synonym |
| “The function returns a predicate” | Produce a SQL condition such as department_id = 10 |
| “Added to any query” | Dynamically modify SQL accessing the protected relation |
| “System administrator” | Configure database-level access-control policies |
These clues identify fine-grained access control implemented through Oracle VPD. Oracle documentation explains that a protected object’s SQL statement is dynamically modified with a WHERE condition returned by a policy function.
Footnotes
-
Using Oracle Virtual Private Database to Control Data Access - Describes predicates as dynamically generated
WHEREconditions. ↩
2. How VPD Works
A VPD policy normally consists of:
- A protected relation, such as a table or view.
- A policy function.
- A policy definition that links the function to the relation.
- A returned predicate.
- Database enforcement during query processing.
The policy function can use session information, application context, user identity, roles, or other database information to determine the appropriate predicate.
A simplified conceptual model is:
For a query on orders, the policy function might return:
1customer_id = SYS_CONTEXT('APP_CTX', 'CUSTOMER_ID')
The database then ensures that a customer sees only the rows associated with that customer.
Footnotes
VPD Query-Processing Workflow
- 1Step 1
Oracle detects that the query references a table, view, or synonym with an attached VPD policy.
- 2Step 2
The database calls the function associated with the policy. The function can inspect the current user, session, application context, or other authorized information.
- 3Step 3
The function returns a SQL condition, such as
department_id = 10orcustomer_id = SYS_CONTEXT(...). - 4Step 4
Oracle dynamically applies the returned condition to the statement, generally as an additional
WHERErestriction. - 5Step 5
The database executes the secured form of the query and returns only rows permitted by the predicate.
- 6Step 6
Depending on its configuration, the policy can apply to operations such as
SELECT,INSERT,UPDATE, andDELETE.
3. A Conceptual Example
Assume an employees table contains:
| employee_id | employee_name | department_id | salary |
|---|---|---|---|
| 101 | Asha | 10 | 72000 |
| 102 | Mateo | 20 | 68000 |
| 103 | Lin | 10 | 75000 |
A user submits:
1SELECT employee_id, employee_name, salary 2FROM employees;
The VPD policy function determines that the user belongs to department 10 and returns:
1department_id = 10
The effective query becomes conceptually:
1SELECT employee_id, employee_name, salary 2FROM employees 3WHERE department_id = 10;
The user sees Asha and Lin, but not Mateo. The application does not need to add a department filter to every query.
This is row-level security because authorization is applied at the row level rather than only at the table level.
Footnotes
-
Using Oracle Virtual Private Database to Control Data Access - Examples of row-level restrictions based on session attributes. ↩
4. The Oracle DBMS_RLS Interface
In Oracle Database, VPD policies are commonly administered through the DBMS_RLS package. The ADD_POLICY procedure associates a policy function with a database object and specifies the operations to which the policy applies.
Important conceptual parameters include:
| Parameter | Purpose |
|---|---|
object_schema | Schema containing the protected object |
object_name | Table, view, or synonym being protected |
policy_name | Name of the VPD policy |
function_schema | Schema containing the policy function |
policy_function | Function that returns the predicate |
statement_types | SQL operations governed by the policy |
static_policy | Indicates whether the predicate is stable and can be reused |
sec_relevant_cols | Supports policies triggered by relevant columns |
The policy function commonly has access to the schema and object names and returns a character value containing a valid SQL predicate. Oracle’s documentation describes predicates as conditions dynamically added to statements accessing protected objects.
Footnotes
-
Restricting Access with Oracle Virtual Private Database - Oracle documentation describing policy-function configuration. ↩
-
DBMS_RLS - Oracle package reference for VPD policy administration. ↩
Security Warning
A VPD predicate is security logic, not ordinary application filtering. Test it against direct SQL, views, synonyms, joins, updates, deletes, and unexpected session-context values.
5. Dynamic Predicates and Session Context
A VPD function can generate different predicates for different users or sessions. For example:
- An administrator may receive
1 = 1, allowing all rows. - A manager may receive
department_id IN (10, 20). - An employee may receive
employee_id = 101. - An unauthorized session may receive
1 = 0, returning no rows.
Oracle supports application contexts through SYS_CONTEXT. A policy function can read context attributes established for the current session and use them to produce an appropriate predicate.
A generalized predicate-selection model is:
Here:
- is the current user.
- is the session or application context.
- represents a candidate row.
- is the security predicate.
Footnotes
-
Using Oracle Virtual Private Database to Control Data Access - Explains application contexts and session-dependent predicates. ↩
Conceptual Visibility Under Different VPD Policies
Illustrative number of rows visible to different user categories in a 1,000-row relation
6. VPD Compared with the Other Options
The alternatives describe identity or authentication technologies rather than predicate-based database row filtering.
| Option | Primary purpose | Returns a SQL predicate for a relation? |
|---|---|---|
| OpenID | Federated identity and authentication | No |
| Single-site system | An architectural deployment arrangement | No |
| Security Assertion Markup Language (SAML) | XML-based exchange of authentication and authorization assertions | No |
| Virtual Private Database (VPD) | Dynamic database access control using policy predicates | Yes |
OpenID and SAML operate primarily in the identity and federation layer. SAML allows an identity provider to communicate authentication information to a service provider, whereas VPD changes how the database evaluates access to protected relations.
A single-site system describes deployment scope, not a database policy mechanism.
Therefore, only VPD matches every part of the question.
Footnotes
-
How OpenID Connect Works - OpenID Foundation comparison of OpenID Connect and SAML. ↩
Common Exam and Design Questions
7. Strengths and Limitations
Strengths
- Centralized enforcement inside the database.
- Reduced dependence on application-layer filters.
- Dynamic behavior based on users, roles, and session context.
- Support for multi-tenant and departmental data isolation.
- Ability to apply policies to multiple SQL operation types.
- Transparent enforcement for direct and application-generated SQL.
Limitations and Risks
- Incorrect predicates can expose data or block legitimate access.
- Complex policy functions can affect parse and execution performance.
- Connection pooling requires careful session-context management.
- Privileged users and administrative bypass behavior must be reviewed.
- Policies must be tested with joins, views, synonyms, stored procedures, and bulk operations.
- Predicate logic should avoid unsafe string construction and unintended SQL behavior.
A useful security principle is:
Footnotes
-
Using Oracle Virtual Private Database to Control Data Access - Oracle description of transparent policy enforcement for protected objects. ↩
Designing a Basic VPD Policy
- 1Step 1
State precisely which users may see or modify which rows. For example, customers may access only orders whose
customer_idmatches their session identity. - 2Step 2
Select the table, view, or synonym to which the policy should apply.
- 3Step 3
Set user, tenant, department, or role attributes through a controlled application context rather than trusting arbitrary client input.
- 4Step 4
Return a valid predicate that expresses the authorization rule. Include a safe default for missing or invalid context.
- 5Step 5
Use the database’s row-level security administration interface, such as Oracle
DBMS_RLS, to associate the function with the object. - 6Step 6
Verify administrators, ordinary users, unauthorized users, direct SQL clients, pooled sessions, and all relevant DML operations.
- 7Step 7
Audit policy behavior, review changes, and periodically confirm that the predicate still matches the organization’s authorization requirements.
VPD Knowledge Check
Memory Aid
If a question mentions a relation, a policy function, a returned predicate, and automatic query restriction, think VPD or row-level security, not an authentication protocol.
Knowledge Check
Which option allows a system administrator to associate a function with a relation, where the function returns a predicate added to queries?