How to implement Deep Data Security (DeepSec) in Oracle 26ai: complete step-by-step guide (part one)

Comments 0

Share to social media

So you’ve been tasked with deploying a Generative AI, RAG (retrieval-augmented generation), or Agentic AI application. Have you thought about how to secure your most sensitive structured data – as well as your vectorized unstructured data?

The good news is, it’s relatively simple to implement complex security policies through the latest release ­of Oracle Database 26ai Deep Data Security (DeepSec).

In this guide, part one of my Oracle 26ai Deep Data Security (DeepSec) series, I’ll show you how – and will explain everything you need to know along the way.

Welcome to a security nightmare

Imagine this scenario. You’re the only Oracle DBA on a team of seasoned application developers, and you’ve just received a new mandate from the Chief of Police. Passed down from the new Mayor, the mandate involves implementing an AI-enabled chatbot that’ll access public and private information about crimes committed within the City.

The Chief wants to make it simpler for authorized personnel – such as district commanders, detectives, cops on the beat, criminologists, reporters, etc – to review data on crimes dating back to 2001. The Chief also knows that there is sensitive data within the current database that not everyone should see.

So, he needs you to guarantee one thing: only law enforcement personnel with proper permissions and clearances should see that information.

How do you achieve this level of privacy?

The basic ERD (entity relationship diagram) below shows how crime data is organized within the CPD schema. The callouts illustrate the complexity of the data security policies you’ll need to implement to ensure each user only sees the data they’re permitted to see.

An image showing Chicago Police Department (CPD) schema and security requirements.
Chicago Police Department (CPD) schema and security requirements.

Implementing data security requirements already looks a bit tricky, even with only five database objects. Now imagine how difficult it would be to build a comprehensive security strategy with only a series of database views that restrict viewing of specific rows within some tables for each user, based on which police district(s) they’re currently assigned to.

All while simultaneously hiding content of specific columns within other tables, of course.

Another crucial requirement is the ability to immediately reassign security privileges whenever a law enforcement officer (LEO) needs to urgently view data.

Perhaps they’ve been assigned to investigating crimes in one or more police district, or they’re restricted from viewing crime data that’s been marked as sensitive, secret, or confidential. They now need access to the data, and fast.

What about when it all goes wrong?

We’ve all watched enough police procedurals to know what happens when it goes wrong for a LEO. Let’s say, for example, they’re suddenly under investigation for bribery. The immediate result? They need to be blocked – urgently – from seeing internal affair reports on their potentially illicit activity.

What about a copper whose close friend has been accused of domestic violence? Perhaps the friend wants to find out what particulars their victim has reported? Worse still, maybe even find out in which shelter the victim now resides?

In all of these cases, the implications of poor security administration are potentially devasting. Fortunately, you’re reading this article, so the answer is simple. You must implement Oracle 26ai Deep Data Security (DeepSec).

Why data security is a complex web of limiting access

I first began investigating Oracle database security features a few years ago, during a stint as DBA for an Oracle Database 19c project. The DBA team I advised needed to implement a sure-fire method to limit users from viewing or changing data they shouldn’t.

The team had already attempted to implement Virtual Private Database (VPD), but with limited success. They’d rolled back their efforts after extreme frustration, and with good reason. Their complex data security requirements spanned dozens of tables, views, and materialized views across multiple schemas.

After some research, I helped them prototype a new security model using Real Application Security (RAS), VPD’s successor.

We also needed to tackle unexpected issues to implement RAS. We needed it to enforce row-level and column-level security within several robust and complex Application Express (APEX) applications. It didn’t help that, at the time, reliable documentation on how to integrate RAS with APEX was lacking.

Protect your data. Demonstrate compliance.

With Redgate, stay ahead of threats with real-time monitoring and alerts, protect sensitive data with automated discovery & masking, and demonstrate compliance with traceability across every environment.
Learn more

That wasn’t all…

There was one final wrinkle – my client’s user base, which also included several “power users”. These users typically used either SQL*Plus or SQL Developer to access their production database directly. They would then extract data in read-only mode for their own data warehouses or analytics. This meant we had to configure these power users as external RAS users.

Further, my client didn’t have the funding (or expertise) to set up an identity management system like Microsoft Active Directory (AD) or Oracle Identity Access Management (IAM). We therefore had to rebuild the security control mechanisms that were stored within their central database.

Last year I wrote about how RAS would be deployed in this scenario for the CPD schema within an Oracle 26ai database. I followed it up by explaining how RAS worked in concert with an AI chatbot deployed through Oracle APEX to limit end users from viewing outside their range of privileges.

That’s a good counterpoint to what I’ll be showing in this article, as well as future entries in the series. I suggest having a look at them before reading on.

How to implement Oracle DeepSec

The good news is, if you’re working with APEX 24.2 and Oracle Database 26ai, DeepSec is easy to implement. It’s also perfect for limiting access to data at both the row and column level with APEX applications.

Let’s focus on a typical workflow (below) to implement Oracle DeepSec. I’ll run through the whole process step-by-step, in detail.

An image showing a Oracle DeepSec implementation strategy.
Oracle DeepSec implementation strategy.

Prerequisites and assumptions before getting started

The rest of this article assumes the following prerequisite steps have already been completed:

  • A 26ai Autonomous Database (ADB) has already been created. It must be patched to version 23.26.2 to enable DeepSec features.

  • The CPD schema has already been created, populated with data, and all constraints and indexes have been applied. You can review the scripts to create and populate the CPD schema from this Github repository.

How to set Oracle DeepSec user limits (step 1)

First, create a new table (called it DEEPSEC_SECURED_USERS) within the CPD schema.

This is to hold specific security permissions and other information about each application user:

You’ll need to populate this control table with data for each user, like what I did below:

A table showing end user permissions.
End user permissions. Note that only a few entries are shown here.
  • In this example, LSNELLING is the current Chief of Police. They have access to data from all CPD Districts, permission to view data in all columns, and permission to view rows at all four security levels.

  • Meanwhile, research assistant SNGUYEN only has access to data in a few districts – but can see report information at all four security levels.

  • User WJACKSON has extremely limited permissions as they’ve recently been reassigned to a new district due to ongoing Internal Affairs investigations.

  • Finally, NKURCHAWSKA is a student research assistant so has very limited privileges for just a few districts. They also can’t view any detailed report information.

Now, it’s on to creating Oracle DeepSec end users.

How to create Oracle DeepSec end users (step 2)

Since I’m working on an OCI-based 26ai autonomous database, for this example I’ll use the ADMIN account as my Oracle DeepSec administrator account. However, if you want to further isolate security administration to another user, you could also create a separate account – say, SECADM for my example.

On how to create Oracle DeepSec end users, you must firstly create DeepSec user accounts for each of them using the CREATE END USER command. Here’s how that works with my four example users:

It’s important to note these are not regular database user accounts – they are specific to DeepSec security only. You use these DeepSec user accounts to connect to your database. It’s the same whether you’re using SQLcl, SQL*Plus, SQLDeveloper, or another database application written in APEX, Python, or Java.

How to create database roles in Oracle DeepSec (step 3)

To grant Oracle DeepSec access to specific tables within a schema, you need to create database roles that grant the required system privileges and different levels of access to database objects.

For my example, I created the following three database roles within the CPD schema:

  • Role ADB_CONNECT just grants CREATE SESSION permissions.

  • Role CPD_READONLY grants read-only access to the CPD schema’s reference tables.

  • And role CPD_FULLDML grants additional DML (data manipulation language) access to those same reference tables.

How to create data roles in Oracle DeepSec (step 4)

To enable Oracle DeepSec end user accounts to access database objects, you must create individual DeepSec data roles and grant them the required access.

For my example, I granted them access via the traditional database roles I just created:

  • DeepSec data role CPD_DWRO_ROLE enables read-only access via database role CPD_READONLY.

  • DeepSec data role CPD_FULL_ROLE enables DML access via database role CPD_FULLDML. It also receives read access via a grant to CPD_DWRO_ROLE.

I then granted each DeepSec end user account the desired security permissions. End users NKURCHAWSKA, SNGUYEN, and WJACKSON receive just read-only capabilities but, since they’re the Chief of Police, end user LSNELLING receives full DML privileges.

How to create Oracle DeepSec data grants that limit data access (step 5)

It’s now time to create your very first Oracle DeepSec objects. For my example, I’ll be creating three dynamic roles that I’ll later use to assign privileges to DeepSec users as they log into the APEX application.

The CHICAGO_CRIMES table

In my example, the GRANT below enforces restrictions on rows within my table CHICAGO_CRIMES, based on which district(s) a user is allowed to access:

This is an excellent example of the powerful simplicity of Oracle DeepSec’s data security policies.

  • Since no specific column names are mentioned in that first SELECT statement, all columns in the CHICAGO_CRIMES table will be viewable by any DeepSec end user that’s been granted the CPD_DWRO_ROLE DeepSec security role.

  • After a database connection is established, the DeepSec object ORA_END_USER_CONTEXT ’s username attribute contains the end user name.

  • The WHERE clause limits the corresponding DeepSec end user granted the CPD_DWRO_ROLE to only viewing rows with a matching value for DISTRICT (found in the ODS_SECURED_USERS table for each end user.)

The CHICAGO_REPORTS table

In a similar fashion, I can build and apply a DATA GRANT for the CRIME_REPORTS table that limits access to rows with a matching value for the SENSITIVITY column, as found in ODS_SECURED_USERS for the connected DeepSec end user below:

An important note on this data grant (the restriction linking CRIME_ID from CRIME_REPORTS to its parent table)

Since the prior data grant against CHICAGO_CRIMES will limit an end user to viewing rows in specific districts, that additional clause ensures only related rows in CRIME_REPORTS will be viewable based on the foreign key constraint on CRIME_ID.

The CHICAGO_VECTORS table

The last DATA GRANT enforces restrictions on the CRIME_VECTORS table in my example:

This limits access to rows within the table, based on whether the end user has a value of PII (personally-identifiying information) for the VISIBILITY column as found in ODS_SECURED_USERS.

Subscribe to the Simple Talk newsletter

Get selected articles, event information, podcasts and other industry content delivered straight to your inbox.
Subscribe

How to test Oracle DeepSec data grants (step 6)

You can ensure your security polices are configured properly by running some simple SQL queries against tables with Oracle DeepSec DATA GRANT‘s in place.

In my example, since the CPD_DWRO_ROLE role has already been granted to the Oracle DeepSec end users I’ve created, any restrictions and limitations I’ve enabled will take immediate effect.

How to prove the restrictions work as intended (test query #1)

The test query below, for my example, is relatively simple:

It joins together my CHICAGO_CRIMES, CRIME_REPORTS, and CRIME_VECTORS tables, retrieving information from all three to prove that the Oracle DeepSec limitations are working properly.

I can now use this query to demonstrate that the restrictions I put in place for my four end users actually work as they should (based on the DeepSec data grants I’ve built so far.)

Here’s what’s returned when I log into my database as one of my DeepSec END USERs – LSNELLING – and run this query:

An image showing what's returned when Jim logs into his database as one of his Oracle DeepSec end users.
The results for LSNELLING.

This end user can see information from every row in the database because they’re the owner of the data. They can see all districts, all sensitivity levels, and any information in the document embeddings.

When end user SNGUYEN connects and runs this same query, however, they see something quite different:

The results for SNGUYEN.
The results for SNGUYEN.

This is because they can only see information for the districts and sensitivity levels they’re permitted to see.

End user WJACKSON sees a completely different result as well:

What end user WJACKSON sees.
The results for WJACKSON.

WJACKSON can only see information for districts 8 and 10. This is because, if you remember, they’ve been transferred between the two districts due to an ongoing Internal Affairs investigation.

Note, also, that their sensitivity levels were adjusted to limit their viewing of reports deemed CONFIDENTIAL or SECRET.

Finally, when end user NKURCHAWSKA connects and runs this same query, the results are dramatically different than those of the other users:

The results for NKURCHAWSKA.

This user doesn’t have permission to access any data in the CRIME_VECTORS table, as defined in the LIMIT_CRIME_VECTOR_VIEWING DeepSec data grant. So, because my test query links data from all three tables, there are literally no results to return. A NULL set is returned as a result.

How to simulate AI chatbot search results (test query #2)

I’m not quite ready to deploy an AI chatbot yet – that’s for the next article in this series – so I built a simple query to leverage the existing embeddings within the CRIME_VECTORS table:

  • I’ve once again joined the CHICAGO_CRIMES, CRIME_REPORTS, and CRIME_VECTORS tables together, this time by using a CROSS JOIN (Cartesian) operation to retrieve from the CRIME_VECTORS.EMBEDDINGS column.

  • The query then uses the VECTOR_DISTANCE function to compare the cosine distance between the requested search token – in this case, what the AI LLM (large language model) determines is relevant to the concept of corruption.

  • Finally, the FETCH APPROXIMATE clause instructs the query to look for relevant results with a confidence level of 95%, returning only the top three results within what’s returned.

Don’t miss this useful trick

For my example, I need to grant permissions to the LLM I used to create the corresponding embeddings for the document chunks. This is to allow it to connect to my database and access those embeddings within CRIME_VECTORS.

To do this: GRANT SELECT ON MINING MODEL ADMIN.MINILML12V2 TO adb_connect;

What do the DeepSec users see?

One of my DeepSec example users, LSNELLING, sees these results:

The results for LSNELLING.
The results for LSNELLING.

Here, the top three document chunks returned are classified as SECRET, so the Chief of Police has a considerably wider view of corrupt activity within his jurisdiction (including some LEOs and even alderpersons!)

End user SNGUYEN, on the other hand, has a more limited view at a district level – receiving this set of results instead:

The results for SNGUYEN.
The results for SNGUYEN.

The vector distance scores are also higher here than of those for LSNELLING, indicating lower relevance to the context being searched.

Differing further are the results for WJACKSON, who has even narrower permissions for both district and sensitivity levels:

The results for WJACKSON.
The results for WJACKSON.

Lastly, what would user NKURCHAWSKA see? Well, since they don’t have permission to access CRIME_VECTORS, the embeddings are also inaccessible to the simulated chatbot interaction. And – just as I demonstrated for the first test query – no results are returned.

Next steps: implementing DeepSec in Oracle 26ai database applications (and how to do so)

If you’re thinking this has been a lot to absorb, you’re correct! The good news is, DeepSec is dramatically easier to implement than any of its Oracle Database predecessors. Better still, it’s more powerful.

In Part 2 of the series, I’ll explain how to implement Oracle DeepSec security constraints to limit access to sensitive information across a schema.

To do so, I’ll continue with my Chicago Police Department example schema in a sample database application. It’ll include how to deploy and use single sign-on (SSO) credentials to manage end user access.

Simple Talk is brought to you by Redgate Software

Take control of your databases with the trusted Database DevOps solutions provider. Automate with confidence, scale securely, and unlock growth through AI.
Discover how Redgate can help you

FAQs: How to implement Oracle DeepSec in Oracle Database 26ai

1. What is Oracle DeepSec in Oracle Database 26ai?

DeepSec (Deep Data Security) is a security framework in Oracle Database 26ai that lets administrators enforce row-level and column-level access controls across structured tables and vectorized data using DeepSec end users, data roles, and data grants.

2. How is DeepSec different from VPD or RAS?

DeepSec is designed to be significantly easier to configure than Virtual Private Database (VPD) or Real Application Security (RAS), especially for complex, multi-table security policies, while still supporting granular row- and column-level restrictions.

3. What are the main components needed to set up DeepSec?

A typical DeepSec setup includes a control table for user permissions, DeepSec end user accounts, standard database roles for object-level privileges, DeepSec data roles, and data grants that define row-filtering logic.

4. Can DeepSec restrict access to vector embeddings used by AI chatbots?

Yes. DeepSec data grants can limit which users or applications can query specific rows in a vector table (such as one holding document embeddings), which controls what an AI chatbot or LLM-powered search can retrieve on a user’s behalf.

5. What Oracle version and patch level are required for DeepSec?

This guide uses a 26ai Autonomous Database patched to release 23.26.2, along with Oracle APEX 24.2, as prerequisites for DeepSec features.

This document contains proprietary information and is protected by copyright law.

Copyright © 2026 Red Gate Software Limited. All rights reserved

Article tags

About the author

Jim Czuprynski

See Profile

Jim Czuprynski has 40+ years of professional experience in Information Technology, serving diverse roles at various Fortune 1000 companies before becoming an Oracle DBA in 2001. An Oracle ACE Director since 2014, Jim is a sought-after public speaker on Oracle technology, presenting often at Oracle CloudWorld, ODTUG Kscope, Oracle Development Community tours, and Oracle User Group conferences around the world. Jim has authored 100+ articles on Oracle Database administration, ML/Analytics, and APEX since 2003 and has co-authored four books on Oracle database technology. Jim’s blog, Generally … It Depends (https://jimthewhyguy.com/blog), contains his regular observations on all things Oracle and the state of the IT industry. Find Jim on BlueSky: @jimthewhyguy.bsky.social‬

Jim's contributions