Virtual Private Database (VPD): Predicate-Based Database Security

Virtual Private Database (VPD): Predicate-Based Database Security

Verified Sources
Sep 11, 2026

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

  1. Restricting Data Access Using the Virtual Private Database - Oracle overview of VPD policy functions and predicates.

  2. 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:

ClueMeaning
“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

  1. Using Oracle Virtual Private Database to Control Data Access - Describes predicates as dynamically generated WHERE conditions.

2. How VPD Works

A VPD policy normally consists of:

  1. A protected relation, such as a table or view.
  2. A policy function.
  3. A policy definition that links the function to the relation.
  4. A returned predicate.
  5. 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:

Effective Query=User Query+VPD Predicate\text{Effective Query} = \text{User Query} + \text{VPD Predicate}

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

  1. DBMS_RLS - Oracle reference for row-level security policy functions and predicates.

VPD Query-Processing Workflow

  1. 1
    Step 1

    Oracle detects that the query references a table, view, or synonym with an attached VPD policy.

  2. 2
    Step 2

    The database calls the function associated with the policy. The function can inspect the current user, session, application context, or other authorized information.

  3. 3
    Step 3

    The function returns a SQL condition, such as department_id = 10 or customer_id = SYS_CONTEXT(...).

  4. 4
    Step 4

    Oracle dynamically applies the returned condition to the statement, generally as an additional WHERE restriction.

  5. 5
    Step 5

    The database executes the secured form of the query and returns only rows permitted by the predicate.

  6. 6
    Step 6

    Depending on its configuration, the policy can apply to operations such as SELECT, INSERT, UPDATE, and DELETE.

3. A Conceptual Example

Assume an employees table contains:

employee_idemployee_namedepartment_idsalary
101Asha1072000
102Mateo2068000
103Lin1075000

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

  1. Using Oracle Virtual Private Database to Control Data Access - Examples of row-level restrictions based on session attributes.

1CREATE OR REPLACE FUNCTION employee_security_policy ( 2 schema_name IN VARCHAR2, 3 object_name IN VARCHAR2 4) 5RETURN VARCHAR2 6AS 7BEGIN 8 RETURN 'department_id = SYS_CONTEXT(''APP_CTX'', ''DEPARTMENT_ID'')'; 9END; 10/

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:

ParameterPurpose
object_schemaSchema containing the protected object
object_nameTable, view, or synonym being protected
policy_nameName of the VPD policy
function_schemaSchema containing the policy function
policy_functionFunction that returns the predicate
statement_typesSQL operations governed by the policy
static_policyIndicates whether the predicate is stable and can be reused
sec_relevant_colsSupports 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

  1. Restricting Access with Oracle Virtual Private Database - Oracle documentation describing policy-function configuration.

  2. 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:

P(u,c,r)={1=1,if the user is an administratorr.department_id=c.department_id,if the user is a managerr.owner_id=u.user_id,if the user is an individual customer1=0,if access is deniedP(u, c, r) = \begin{cases} 1 = 1, & \text{if the user is an administrator} \\ r.\text{department\_id} = c.\text{department\_id}, & \text{if the user is a manager} \\ r.\text{owner\_id} = u.\text{user\_id}, & \text{if the user is an individual customer} \\ 1 = 0, & \text{if access is denied} \end{cases}

Here:

  • uu is the current user.
  • cc is the session or application context.
  • rr represents a candidate row.
  • PP is the security predicate.

Footnotes

  1. 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.

OptionPrimary purposeReturns a SQL predicate for a relation?
OpenIDFederated identity and authenticationNo
Single-site systemAn architectural deployment arrangementNo
Security Assertion Markup Language (SAML)XML-based exchange of authentication and authorization assertionsNo
Virtual Private Database (VPD)Dynamic database access control using policy predicatesYes

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

  1. 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:

Effective Security=Correct Policy Logic+Correct Context Management+Comprehensive Testing\text{Effective Security} = \text{Correct Policy Logic} + \text{Correct Context Management} + \text{Comprehensive Testing}

Footnotes

  1. Using Oracle Virtual Private Database to Control Data Access - Oracle description of transparent policy enforcement for protected objects.

Designing a Basic VPD Policy

  1. 1
    Step 1

    State precisely which users may see or modify which rows. For example, customers may access only orders whose customer_id matches their session identity.

  2. 2
    Step 2

    Select the table, view, or synonym to which the policy should apply.

  3. 3
    Step 3

    Set user, tenant, department, or role attributes through a controlled application context rather than trusting arbitrary client input.

  4. 4
    Step 4

    Return a valid predicate that expresses the authorization rule. Include a safe default for missing or invalid context.

  5. 5
    Step 5

    Use the database’s row-level security administration interface, such as Oracle DBMS_RLS, to associate the function with the object.

  6. 6
    Step 6

    Verify administrators, ordinary users, unauthorized users, direct SQL clients, pooled sessions, and all relevant DML operations.

  7. 7
    Step 7

    Audit policy behavior, review changes, and periodically confirm that the predicate still matches the organization’s authorization requirements.

VPD Knowledge Check

1 / 6
Question · Term

What does VPD stand for?

Click to reveal
Answer · Definition

Virtual Private Database.

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

Question 1 of 5
Q1Single choice

Which option allows a system administrator to associate a function with a relation, where the function returns a predicate added to queries?