๐Ÿ“ž +880 1715-151882 โœ‰๏ธ info@khannasir.com

The Oracle Account an AI Agent Should Connect As

Somebody in the business has asked for an AI assistant that can answer questions from the ERP, and the request has landed on your desk as one line: give it access to the database. What you grant in the next ten minutes is the whole security design.

The short answer: create an account that owns nothing, grant it READ on a handful of views rather than SELECT on tables, attach a profile that aborts a runaway call, name the human behind every question, and audit what it reads.

The rest of this article is those steps in order, with the exact statements and Oracle's own documentation behind each one.

Picture the shape it usually arrives in, because it is an easy one to end up in. A team has a working prototype on a developer's laptop, it connects as the application owner because that was the connection string lying around, and now somebody wants it pointed at production.

The prototype is not the problem. The connection string is.

Key Takeaways

  • Oracle's own guideline is blunt: "Do not provide database users or roles more privileges than are necessary."
  • Grant READ, not SELECT. Oracle says READ "Does not allow SELECT โ€ฆ FOR UPDATE", and that every object privilege except READ lets the grantee lock the table with LOCK TABLE.
  • Point the agent at views. Oracle lists one purpose of a view as to "Provide an additional level of table security by restricting access to a predetermined set of rows or columns of a table".
  • A profile with CPU_PER_CALL stops a runaway call: the database "aborts the operation, rolls back the current statement, and returns an error, leaving the current transaction intact".
  • The agent can read its own schema with no extra privilege โ€” ALL_TAB_COLUMNS "describes the columns of the tables, views, and clusters accessible to the current user".
  • DBMS_SESSION.SET_IDENTIFIER puts the human's name in the audit trail, but it "is executable by public", so it is a label, not a lock.
  • None of this stops a prompt-injected agent from answering honestly with data it is allowed to read. Privileges decide the blast radius, not the intent.
Open books displayed under glass cases along a museum table, readable but untouchable
Read it, do not touch it. That is a database privilege, and Oracle has a name for it. Illustrative photograph. Photo: mali maeder / Pexels

1. Why the Application's Own Account Is the Wrong One to Lend

The application owner is the schema that owns the tables. It can read every column, write every row, drop every object, and on an older schema it may well hold grants on packages nobody has reviewed in years.

Lending that account to an assistant is not a small shortcut. It is the entire difference between a mistake that returns a wrong number and a mistake that changes one.

Oracle's guideline for securing user accounts puts it plainly: "Do not provide database users or roles more privileges than are necessary. (If possible, grant privileges to roles, not users.) In other words, the principle of least privilege is that users be given only those privileges that are actually required to efficiently perform their jobs."

That sentence predates language models by many years. It did not need updating for them.

Three things change when the caller is a model

  • The statement is written at request time. Nobody reviewed it before it ran, so the review has to be a privilege, not a meeting.
  • The input comes from outside. A question can carry instructions, which is the whole subject of prompt injection and how to defend against it.
  • The volume is different. Put illustrative figures on it: where a person might ask six questions in an hour, an agent in a loop can ask hundreds. Measure your own rate rather than trusting mine โ€” the point is the order of magnitude, because a query that was merely inefficient becomes a load problem at that volume.

So the design goal is not "stop the model being wrong". It is to make its worst plausible mistake survivable.

That is the same instinct behind the wider Oracle hardening work I describe elsewhere: assume something will get through, then decide in advance how far it can go.

2. Step One: an Account That Owns Nothing

Create a dedicated user for the agent. It owns no tables, has no quota on any tablespace, and holds exactly one system privilege.

Oracle's CREATE USER page notes the useful starting point: "When you create a user with the CREATE USER statement, the user's privilege domain is empty." Everything it can do afterwards is something you consciously added.

The same page tells you the one thing it must have: "To log on to Oracle Database, a user must have the CREATE SESSION system privilege."

-- Run as a DBA, connected with SQL*Plus or SQLcl. Every statement below CHANGES
-- the database: it belongs in change control, not in an idle afternoon.
-- PREREQUISITE: ai_agent_profile is created in step five. Create it first, or drop
-- the PROFILE clause here and attach the profile with ALTER USER once it exists.

CREATE USER ai_agent
  IDENTIFIED BY "<a long random password nobody types by hand>"
  DEFAULT TABLESPACE   users
  TEMPORARY TABLESPACE temp
  PROFILE              ai_agent_profile;

GRANT CREATE SESSION TO ai_agent;

-- the alternative, if you would rather create the profile later:
-- ALTER USER ai_agent PROFILE ai_agent_profile;

The order these run in

The steps below are written for reading, not for pasting top to bottom. Run them in this order on a schema whose base tables already exist:

  1. CREATE PROFILE ai_agent_profile (step five).
  2. CREATE USER ai_agent and GRANT CREATE SESSION (this step).
  3. CREATE OR REPLACE VIEW for every view the agent will see (step three), as the schema owner.
  4. GRANT READ on each of those views (step two) โ€” a grant on a view that does not exist yet fails with ORA-00942.
  5. COMMENT ON, the audit policy and the Resource Manager directive, in whatever order suits your change window.

Notice what is not in that CREATE USER statement.

There is no QUOTA clause, and there is no GRANT UNLIMITED TABLESPACE. Oracle describes QUOTA as the clause used "to specify the maximum amount of space the user can allocate in the tablespace", so an account that never receives one has nowhere to put a table even if somebody later grants it CREATE TABLE by accident.

There is no CONNECT role and no RESOURCE role either. Oracle's own account guidelines list revoking "The RESOURCE role from typical application accounts" and "The CONNECT role from typical application accounts" among the things to do, and an agent is a more extreme case of the same idea.

The PROFILE clause names the profile created in step five, which is why the order above puts that step first. If you leave the clause out, Oracle tells you what happens: "If you omit this clause, then Oracle Database assigns the DEFAULT profile to the user." The DEFAULT profile is usually generous, which is the opposite of what we want here.

One account per purpose, not one per model

I keep one account per job, not one per vendor. A reporting assistant and a ticket-triage assistant have different questions and different data, so they get different accounts and different views.

It costs nothing, and the day you need to switch one off you can do it without arguing about who else uses it.

3. Step Two: READ, Not SELECT

SELECT is the word that comes to hand, because it is the one everybody learns first. For an account that must never write anything, READ is the more exact privilege, and the difference is real.

Oracle's GRANT reference defines the table privilege READ as "Query the table with the SELECT statement" and adds a sentence that matters: "Does not allow SELECT โ€ฆ FOR UPDATE."

Then it says something stronger about every other privilege in the list: "Any one of following object privileges, except the READ privilege, allows the grantee to lock the table in any lock mode with the LOCK TABLE statement."

Read that twice if you have ever spent an evening chasing a blocking session.

An account with SELECT can take row locks and table locks. An account with READ cannot. A model that writes SELECT ... FOR UPDATE because it saw the pattern in its training data will simply be refused, instead of quietly holding a lock while your night batch waits behind it.

The security guidelines page says the same thing as advice: "If you want to restrict users to only being able to query tables, views, materialized views, and synonyms, then grant users the READ object privilege, or for trusted users only, the READ ANY TABLE system privilege."

The "for trusted users only" half of that sentence is doing a lot of work. An AI agent is not a trusted user in this sense, so READ ANY TABLE is not on the table, and neither is SELECT ANY TABLE โ€” which the same reference notes also lets the holder "Obtain row locks using a SELECT ...".

-- right: one object at a time, read only.
-- PREREQUISITE: both views are created in step three, below. Run that first.
GRANT READ ON app.v_ai_order_summary  TO ai_agent;
GRANT READ ON app.v_ai_stock_position TO ai_agent;

-- wrong, in ascending order of regret
-- GRANT SELECT          ON app.orders TO ai_agent;   -- allows FOR UPDATE and LOCK TABLE
-- GRANT READ ANY TABLE  TO ai_agent;                 -- every schema, forever
-- GRANT SELECT ANY TABLE TO ai_agent;                -- the above, plus row locks

If the grant list is too long to read aloud in a meeting, it is too long.

An open shuttered window framing a view of tiled rooftops and a bell tower
A view shows a predetermined slice of what is out there, and nothing else. That is the whole idea. Illustrative photograph. Photo: Bob Jenkin / Pexels

4. Step Three: Views, Never the Base Tables

The agent should not know your table names. It should know a small set of views whose names, columns and row ranges you chose deliberately.

Oracle Database Concepts lists this as one of the reasons views exist: to "Provide an additional level of table security by restricting access to a predetermined set of rows or columns of a table". The same page adds that "Unlike a table, a view is not allocated storage space, nor does a view contain data."

So a view costs you no storage and buys you three separate things at once.

  • Columns you leave out cannot leak. The customer's phone number, the national ID, the cost price and the salary are simply not in the result set the agent can reach.
  • Rows you leave out cannot leak either. A WHERE clause in the view definition is the cheapest row filter you will ever write.
  • The model writes better SQL. Concepts also lists "Hide data complexity" as a purpose: one view can carry the join you would otherwise hope the model guesses right.
-- Run as APP, the schema that owns ORDERS, CUSTOMERS, STOCK and ITEMS, so no
-- cross-schema grant is needed. Those base tables are assumed to exist already;
-- the column names below are an example shape, not yours.
CREATE OR REPLACE VIEW app.v_ai_order_summary AS
SELECT o.order_id,
       o.order_date,
       o.status,
       c.customer_name,
       c.region,
       o.total_amount
FROM   app.orders    o
JOIN   app.customers c ON c.customer_id = o.customer_id
-- The cut-off is the first day of the month 24 months back, so the window is
-- the current month plus the 24 whole months before it. Shift the -24 or use a
-- plain date literal if you need a different boundary.
WHERE  o.order_date >= ADD_MONTHS(TRUNC(SYSDATE, 'MM'), -24);

-- The second view the grant list and the audit policy both refer to.
CREATE OR REPLACE VIEW app.v_ai_stock_position AS
SELECT i.item_code,
       i.item_name,
       i.category,
       s.warehouse_code,
       s.quantity_on_hand,
       s.last_counted_date
FROM   app.stock s
JOIN   app.items i ON i.item_id = s.item_id
WHERE  i.is_active = 'Y';

GRANT READ ON app.v_ai_order_summary  TO ai_agent;
GRANT READ ON app.v_ai_stock_position TO ai_agent;

No phone number, no address, no discount workings, and no cost price โ€” and on the order view, nothing from before that month boundary. If somebody later asks for 2019 data, that is a conversation and a new view, not a surprise.

One detail trips people up when the views live in a different schema from the tables. Oracle's CREATE VIEW prerequisites say the owner of the schema containing the view must hold the base privileges, and adds: "The owner must be granted these privileges directly, rather than through a role."

Keeping the views in the same schema as the tables, as above, avoids the whole question. It also keeps the view definition next to the data it describes, where the next DBA will find it.

Name the views so the model cannot miss the point

I prefix them V_AI_. It reads clearly in a grant list, it greps cleanly, and when somebody asks "what can that thing see?" the answer is one query away.

5. Step Four: the Schema It Can Read Is the Prompt It Gets

A text-to-SQL agent needs your schema to write SQL. It does not need a dictionary privilege to get it, and that is one of the quietly elegant parts of this design.

Oracle's reference for ALL_TAB_COLUMNS says it "describes the columns of the tables, views, and clusters accessible to the current user".

So when the agent runs the query below under its own login, the answer is its permitted surface. Not a filtered copy of your schema that somebody has to keep in step โ€” the real thing, narrowed by the grants you already made.

-- The agent runs this itself at startup. No extra privilege is needed:
-- ALL_TAB_COLUMNS already shows only what this user can reach.
SELECT c.table_name,
       c.column_name,
       c.data_type,
       c.nullable,
       m.comments
FROM   all_tab_columns  c
LEFT   JOIN all_col_comments m
       ON  m.owner      = c.owner
       AND m.table_name = c.table_name
       AND m.column_name = c.column_name
WHERE  c.owner = 'APP'
ORDER  BY c.table_name, c.column_id;

The comments column is where the real gain is. ALL_COL_COMMENTS "displays comments on the columns of the tables and views accessible to the current user", so anything you write with COMMENT ON COLUMN reaches the model as documentation.

COMMENT ON TABLE app.v_ai_order_summary IS
  'One row per customer order, last 24 months. Amounts are in BDT and include VAT.';

COMMENT ON COLUMN app.v_ai_order_summary.status IS
  'NEW, PACKED, SHIPPED, DELIVERED or CANCELLED. Cancelled orders are kept, not deleted.';

COMMENT ON COLUMN app.v_ai_order_summary.total_amount IS
  'Order value including VAT. Freight is not included.';

Those three comments hand the model the context behind three easy mistakes: double-counted cancellations, a VAT figure reported twice, and freight silently folded into revenue. Context is not a guarantee โ€” test the SQL it writes against each of the three and see.

They are also the cheapest documentation you will ever write, because they live in the database instead of in a document nobody opens. I make a habit of adding them while designing the view, not afterwards.

This is the same discipline I describe in my guide to designing an Oracle indexing strategy: write down the intent where the database can carry it, so the next person does not have to infer it.

A corridor lined with numbered grey electrical breaker cabinets
A limit is something you set before the run, not something you decide during it. Illustrative photograph. Photo: Kostiantyn Klymovets / Pexels

6. Step Five: a Profile That Cancels a Runaway Call

An agent will eventually write a cross join. The question is only whether it finds out in thirty seconds or in thirty minutes.

A profile gives you per-call limits on the account itself, with no extra moving parts.

CREATE PROFILE ai_agent_profile LIMIT
  CPU_PER_CALL            3000      -- hundredths of a second: 30 seconds of CPU per call
  LOGICAL_READS_PER_CALL  2000000   -- data blocks per call, not rows
  CONNECT_TIME            60        -- minutes
  IDLE_TIME               15        -- minutes
  SESSIONS_PER_USER       4;

The unit of CPU_PER_CALL catches people out every time. Oracle's CREATE PROFILE page says: "Specify the CPU time limit for a call (a parse, execute, or fetch), expressed in hundredths of seconds." So 3000 is thirty seconds, not thirty minutes and not three thousand of anything useful.

LOGICAL_READS_PER_CALL is counted in blocks: "Specify the permitted number of data blocks read for a call to process a SQL statement (a parse, execute, or fetch)."

What happens when a call crosses the line is the part worth knowing before you set it. Oracle says the database "aborts the operation, rolls back the current statement, and returns an error, leaving the current transaction intact".

That is the behaviour you want for an agent: the bad statement dies, the session survives, and the application can answer the user with an apology rather than a stack trace.

IDLE_TIME has a caveat that is easy to misread. Oracle notes: "Long-running queries and other operations are not subject to this limit." It reclaims abandoned sessions; it does not cut off a long query.

The switch that makes all of it do nothing

Profile resource limits only apply when the instance is told to enforce them. The initialization parameter RESOURCE_LIMIT "determines whether resource limits are enforced in database profiles".

Check it before you trust your own profile.

-- Read-only. Confirm the limits you just wrote are actually enforced.
SHOW PARAMETER resource_limit

SELECT resource_name, limit
FROM   dba_profiles
WHERE  profile = 'AI_AGENT_PROFILE'
AND    resource_type = 'KERNEL'
ORDER  BY resource_name;

Pick the first numbers from your own measurements, not from this article. Run the agent's real questions once under a generous limit, look at what they actually cost, then set the limit above the honest maximum and below the number that would hurt.

Oracle itself prefers the other mechanism. Its CREATE USER page carries the note: "Oracle recommends that you use the Database Resource Manager rather SQL profiles to establish database resource limits." I use both, for the reason in the next section.

7. Step Six: Resource Manager, the Second Brake

A profile limit is a hard stop on one account. Database Resource Manager is a policy about the whole instance, and it can cancel a statement without killing the session that ran it.

The mechanism is a plan directive that switches a session when it crosses a threshold. The documentation describes the reserved group name that interests us here: "When CANCEL_SQL is specified, the current call is canceled when switch criteria are met, but the session is not terminated."

That is a gentler failure than ending the session, and for a pooled connection it matters.

-- SHAPE, not a finished script. The plan must already exist, the consumer group
-- must be mapped to the user, and the switch privilege granted. Check every
-- argument against the Administrator's Guide for your release before running it.
BEGIN
  DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();

  DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(
    consumer_group => 'AI_AGENT_GROUP',
    comment        => 'Sessions opened by the question-answering agent');

  DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
    plan             => 'DAYTIME_PLAN',
    group_or_subplan => 'AI_AGENT_GROUP',
    comment          => 'Cancel an agent call that passes 60 seconds of CPU',
    mgmt_p1          => 10,
    switch_group     => 'CANCEL_SQL',
    switch_time      => 60,
    switch_for_call  => TRUE);

  DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
  DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
END;
/

SWITCH_FOR_CALL is the argument that suits a pooled agent. The documentation explains why: with it set to TRUE, "the session is returned when the current top-level call completes", and it notes that the setting "is useful for three-tier applications where the middle tier server is using session pooling".

In this particular directive you do not actually get a choice, and it is worth knowing why. The same reference says that "If the group name is CANCEL_SQL, then the SWITCH_FOR_CALL parameter is always set to TRUE, overriding the user-specified setting." Passing TRUE above simply writes down what Oracle is going to do anyway. The argument earns its keep when you switch to a real consumer group instead: there, a FALSE leaves the session in the slower group until it goes idle, long after the question that caused it has been answered.

Resource Manager is an Enterprise Edition feature, so check your edition before you design around it. If you are on Standard Edition 2, the profile from step five is doing the whole job, which is a reason to set it carefully rather than a reason to skip it.

8. Step Seven: Name the Human Behind the Question

Every session will be AI_AGENT. Unless you do something about it, your audit trail will record that the robot asked, which is true and useless.

The fix is one call before each question.

-- The application makes this call on the pooled session before it asks anything.
BEGIN
  DBMS_SESSION.SET_IDENTIFIER('hr:rashida.k:req-8841');
END;
/

SELECT SYS_CONTEXT('USERENV', 'CLIENT_IDENTIFIER') FROM dual;

Oracle documents the procedure simply: "This procedure sets the client ID in the session." The value is capped โ€” "The maximum number of bytes for this parameter is 64 bytes. If the input exceeds 64 bytes, the additional bytes are truncated" โ€” so keep the format short and structured.

Mine is department:user:request-id. Sixty-four bytes goes quickly once somebody puts an email address in it.

Now the honest part, and please do not skip it.

The same page says the procedure "is executable by public". Anything connected to that session can set the identifier to any string it likes, including a different person's name.

So treat it as a label that makes your audit trail readable, not as an authorisation control. If a question's answer genuinely depends on who is asking, the boundary belongs higher up, in the application that authenticated the person, and the data boundary belongs in the view โ€” which is the same argument as in permission-aware RAG, where the retrieval layer must not be the place you first check permissions.

A hand writing an entry into a ruled paper visitor register on a wooden stand
A register nobody reads is still better than no register โ€” but only just. Read yours on a schedule. Illustrative photograph. Photo: Connor Scott McManus / Pexels

9. Step Eight: Audit What It Actually Read

You will be asked, probably by an auditor and possibly in a hurry, what the AI has looked at. Decide now that the answer is a query rather than a guess.

A unified audit policy on the agent's own views is small, targeted and cheap.

CREATE AUDIT POLICY ai_agent_reads
  ACTIONS SELECT ON app.v_ai_order_summary,
          SELECT ON app.v_ai_stock_position;

AUDIT POLICY ai_agent_reads BY ai_agent;

The ACTIONS ... ON clause is the documented way to scope a policy to one object: "Use this clause to audit an action on the specified object."

The BY clause is what keeps the policy from auditing your whole user base. Oracle's AUDIT reference says to "Specify the BY clause to enable policy for only the specified users", and warns what happens otherwise: "If you omit the BY and EXCEPT clauses and the by_users_with_roles clause, then Oracle Database enables policy for all users."

Forget the BY clause and you have just started auditing every SELECT on those views from every account in the database. Check it before you leave for the day.

-- Read-only. What has the agent read today, and on whose behalf?
SELECT event_timestamp,
       dbusername,
       client_identifier,
       object_schema,
       object_name,
       sql_text
FROM   unified_audit_trail
WHERE  dbusername = 'AI_AGENT'
AND    event_timestamp > SYSTIMESTAMP - INTERVAL '1' DAY
ORDER  BY event_timestamp;

Those columns are documented exactly as you would hope. CLIENT_IDENTIFIER is the "Client identifier in each Oracle session", so step seven's label appears here; SQL_TEXT is the "SQL associated with the event"; and UNIFIED_AUDIT_POLICIES "Lists the audit policies that caused the current audit record".

Read it weekly for the first month. A short sitting with the real audit rows tells you how the assistant is actually being used, which a demo cannot.

What I look for: the same question repeated hundreds of times (a caching problem), questions arriving at 3 a.m. (an automation nobody mentioned), and queries against a view that was supposed to be for one department.

10. Step Nine: the Connection Itself

The account can be perfect and the connection still careless.

Four things I check before anything is pointed at production.

  • The password is not in a repository. It lives wherever the rest of your application secrets live, and nobody types it. If the agent runs on your own servers, a wallet is better than a string.
  • The agent connects as itself. No proxy to a more powerful user, no "temporarily" running as the app owner while someone debugs.
  • The service name is its own. A separate database service for the agent makes it visible in session views, and makes it possible to stop just this traffic without stopping anything else.
  • The listener and the network are already hardened, which is a subject of its own โ€” I cover it in securing the Oracle listener.

Add one more that costs nothing: write down who owns the account. A login with no named human owner is the one still running three years after the project ended.

11. What This Design Does Not Protect You From

Everything above is about blast radius. None of it is about intent, and pretending otherwise would be the most expensive mistake in this article.

Four limits, stated plainly.

It does not stop prompt injection. If a question, a document or a row of data carries instructions and the agent follows them, the agent is still inside your grants. It reads what it is allowed to read, and the answer goes wherever the answer goes.

It does not stop legitimate reads adding up. Ten honest answers can reconstruct something no single answer was supposed to reveal. Row and column limits help; they do not make aggregation impossible.

It does not stop the answer leaving the building. If the model is hosted elsewhere, your rows cross your boundary when the answer is composed, not when the query runs. That is a hosting decision, and it is why I keep writing about running a private LLM on your own hardware.

It does not review the SQL. A statement can be allowed, cheap and still wrong โ€” the null handling, the join, the implicit conversion. That is a separate discipline, and I set it out in reviewing AI-generated SQL before it runs on Oracle.

Hold those four in mind and the account design above does exactly what it should: it makes the failures small, visible and recoverable.

12. What the Licence Covers, Said Honestly

Most of this article is ordinary SQL. A few pieces are not, and I would rather you check than discover.

The account, the READ grants, the views, the comments, the profile limits and the dictionary queries are plain data definition and data dictionary work.

Database Resource Manager, Virtual Private Database, Oracle Data Redaction and Oracle Database Vault are the features whose availability depends on your edition, and in some cases on a separately licensed option. Check the Licensing Information User Manual for your exact release and edition, and check your own contract, before you design a control around any of them.

I say this because an architecture that quietly assumes Enterprise Edition is an unpleasant discovery for a Standard Edition 2 customer three weeks before go-live.

Everything in steps one to five, step seven and step eight stands on its own if you have nothing but the base database.

13. The Checklist

Print it, work down it, and keep the finished copy with your change record.

  • Account. Dedicated user, one per job. CREATE SESSION only. No quota. No CONNECT, no RESOURCE, no DBA.
  • Privilege. READ, not SELECT. Named objects only. No ANY privilege of any kind.
  • Surface. Views, never base tables. Sensitive columns left out. Row range decided on purpose.
  • Meaning. COMMENT ON every view and every column the model will read.
  • Limits. A profile with CPU_PER_CALL and LOGICAL_READS_PER_CALL, numbers from your own measurements, and RESOURCE_LIMIT confirmed.
  • Second brake. On Enterprise Edition, a Resource Manager directive with CANCEL_SQL and SWITCH_FOR_CALL.
  • Identity. DBMS_SESSION.SET_IDENTIFIER on every request, in a documented format, understood as a label.
  • Audit. A unified audit policy on the agent's views, enabled BY ai_agent, and read weekly.
  • Connection. Its own service, its own password, no proxy, a named human owner.
  • Review date. A diary entry to re-read the grant list in three months, because view lists grow.

On a schema you already know, this is an afternoon of work rather than a project, and far quicker the second time, once the views and the profile are written down. How long it really takes you depends on your schema and your change-control process.

Against that: the alternative is an account that can read every column in the business, held by software that writes its own queries from sentences typed by people who have never seen your schema.

I know which conversation I would rather have with an auditor.

Frequently Asked Questions

Can I just give an AI agent a read-only Oracle user?

A read-only user is the start, not the finish. Create an account with no quota and only CREATE SESSION, grant it READ on a small set of views rather than SELECT on tables, attach a profile with per-call limits, and audit what it reads. Oracle's own guidance is that users should be given only the privileges actually required to do their jobs.

What is the difference between the READ and SELECT privileges in Oracle?

Oracle's GRANT reference says READ lets you query the table with the SELECT statement and "Does not allow SELECT โ€ฆ FOR UPDATE". It also says that any object privilege except READ allows the grantee to lock the table in any lock mode with the LOCK TABLE statement. For an agent that should only ever read, READ is the correct privilege: SELECT would let it take row locks and block your application.

Should an AI agent query tables or views?

Views. Oracle Database Concepts lists one purpose of a view as to "Provide an additional level of table security by restricting access to a predetermined set of rows or columns of a table", and notes that a view is not allocated storage space and contains no data. A view is also where you put the business meaning, so the model writes simpler SQL against a smaller, cleaner surface.

How do I stop an AI-generated query from running away?

Use two layers. A profile with CPU_PER_CALL and LOGICAL_READS_PER_CALL aborts a call that exceeds the limit: Oracle says the database "aborts the operation, rolls back the current statement, and returns an error, leaving the current transaction intact". On Enterprise Edition, Database Resource Manager can switch the session to the reserved group CANCEL_SQL, where "the current call is canceled when switch criteria are met, but the session is not terminated".

Does the agent need SELECT ANY DICTIONARY to know my schema?

No, and that is one of the nicer properties of this design. ALL_TAB_COLUMNS "describes the columns of the tables, views, and clusters accessible to the current user", so when the agent queries it under its own login it gets exactly the surface you granted it and nothing else. Add COMMENT ON COLUMN text and ALL_COL_COMMENTS gives the model your business meanings too.

How do I record which person asked the question?

Have the application call DBMS_SESSION.SET_IDENTIFIER before each question. Oracle documents that this "sets the client ID in the session", that the value is capped at 64 bytes, and that the identifier appears in UNIFIED_AUDIT_TRAIL as the "Client identifier in each Oracle session". Treat it as a label for the audit trail, not as a security control: the same page says the procedure "is executable by public", so anything connected can set it to anything.

Is a read-only account enough to stop prompt injection?

No. A read-only account limits the damage to reading, which is the point, but a prompt-injected agent reading the rows it is allowed to read is still a data leak if the answer leaves the building. Privileges decide the blast radius; they do not decide intent. Keep the grant small enough that the worst honest answer is one you could live with being forwarded.

Do I need Enterprise Edition for any of this?

The account, the READ grants, the views, the profile limits, the comments and unified auditing are ordinary SQL and data dictionary work. Database Resource Manager, Virtual Private Database, Data Redaction and Database Vault are the pieces to check against the Licensing Information User Manual for your exact release, edition and contract before you plan around them.

๐Ÿ” Is something already connected to your database that nobody reviewed?

An AI pilot can reach production on a connection string that was never meant to leave a laptop. I review the accounts, the grants, the views and the limits around them, and leave your team with the checklist above filled in for your own schema.

๐Ÿ“ฉ Book an Oracle Access Review
Nasir Uddin Khan โ€” Oracle DBA Consultant

Nasir Uddin Khan

Nasir is an Oracle Certified Professional and CSV-certified IT consultant based in Dhaka, Bangladesh. He has 18+ years of hands-on experience in Oracle database administration (RAC, Data Guard, RMAN), WebLogic middleware, ERP system design, and AI integration for manufacturing, pharmaceutical, banking, and healthcare organisations worldwide.

References & Further Reading

All Oracle quotations were read from the Oracle Database 19c documentation on 18 November 2026; the dated page text behind every quotation is kept with this article's working files. Table, view and schema names in the examples are illustrative. Every profile number, Resource Manager value and grant list shown is a starting point to replace with your own measurements, and every privilege, feature and licence must be confirmed against the documentation for your exact release and edition before production use.

Related Articles

An AI Assistant Your Auditor Can Live With

Least-privilege account design ยท read-only views ยท resource limits and guard rails ยท unified auditing ยท Oracle health checks. 18+ years of Oracle experience. Bangladesh and worldwide.

๐Ÿ’ฌ