Key Takeaways
- Select AI turns natural-language questions into SQL against your database using an LLM plus schema metadata you control.
- An AI profile binds the provider, credentials, and the list of tables/views the model may see.
- Core actions include show_sql (inspect), run_sql (execute), explain_sql, and narrate.
- Access stays inside database security: object lists, privileges, and row-level policies still apply to generated SQL.
- Python developers use the select_ai package; SQL developers use DBMS_CLOUD_AI and the SELECT AI keyword.
Introduction
Every agent team eventually hits the same wall. The agent can reason, call tools, and keep memory, but the answers that matter live in production tables the team does not want to expose through free-form SQL or copied extracts.
Select AI on Oracle AI Database 26ai (including Autonomous AI Database) provides a governed natural-language path to those tables. You define an AI profile that names the provider, the credential, and the objects the model may consider. The system augments the user question with schema metadata, asks the LLM for SQL, and (optionally) runs or narrates the result—all under the same privileges and policies the database already enforces.
This article walks through a practical path: create a profile, ask a question, inspect the SQL, run it, and (optionally) get a narrated answer. Both the SQL interface and the Python SDK are covered so different developer personas can succeed.
1. What Select AI Is (and Is Not)
Select AI is Oracle’s natural-language layer over enterprise data. Its core production path is NL2SQL: natural language → SQL against tables and views you control. The same framework also supports chat, narration, synthetic data, RAG (where vector search is available), and more advanced agent workflows. This article stays on the NL2SQL foundation that most teams need first.
Select AI is not a replacement for application authorization or row-level security. Generated SQL still runs as the database user. Roles, privileges, Virtual Private Database (VPD) policies, and auditing continue to apply. The profile’s object list limits which metadata the model sees and, when enforcement is enabled, which objects the generated SQL may touch.
2. Core Concepts
AI Profile
A database object that binds:
- Provider and model (OCI Generative AI, OpenAI, Azure OpenAI, and others supported by your release)
- Credential for that provider
- Object list (tables, views, and related objects the model may use)
- Optional settings such as enforce_object_list: when enabled, generated SQL is limited to the objects in the profile list, so the model cannot reach tables outside the approved set even if the underlying database user has broader privileges
Augmented prompt
Select AI sends schema metadata (object and column names, comments) together with the user question so the LLM can produce SQL that matches your actual schema.
Actions
- showsql / show_sql — generate SQL without running it
- runsql / run_sql — generate and execute; return results
- explainsql / explain_sql — surface the model’s reasoning
- narrate — return a natural-language answer over the results
Governance surface
Object list + database privileges + existing VPD/RAS policies + session tagging and audit.
3. Prerequisites
- Autonomous AI Database or a supported Oracle AI Database release with Select AI enabled
- EXECUTE privilege on DBMS_CLOUD_AI (and related packages as required)
- A credential for a supported AI provider
- A least-privilege database user and a scoped set of tables/views
- Network ACLs or private endpoints as required by your environment
- For Python: pip install select_ai and connectivity to the database
Start with a small, well-commented schema. Metadata quality strongly affects SQL quality.
4. Create and Enable an AI Profile (SQL Path)
Create a credential for your provider (exact syntax depends on the provider; see current docs). Then create a profile that limits the model to a known object list:
BEGIN
DBMS_CLOUD_AI.CREATE_PROFILE(
profile_name => 'HR_READONLY',
attributes => '{
"provider": "openai",
"credential_name": "OPENAI_CRED",
"model": "gpt-4o-mini",
"object_list": [
{"owner": "HR", "name": "EMPLOYEES"},
{"owner": "HR", "name": "DEPARTMENTS"}
],
"enforce_object_list": true
}'
);
END;
/
EXEC DBMS_CLOUD_AI.SET_PROFILE('HR_READONLY');
Notes:
- Replace provider, model, and credential with values supported in your environment and release.
- Call SET_PROFILE in each new session that will use Select AI.
- Keep enforce_object_list true while you learn the surface.
Inspect before you run:
SELECT AI SHOWSQL 'how many employees were hired in the last 90 days by department?';
SELECT AI EXPLAINSQL 'how many employees were hired in the last 90 days by department?';
When the candidate SQL looks correct, run it under the same session (or copy the SQL and execute it under a read-only role). Generated SQL is still ordinary SQL: privileges, VPD, and auditing apply.
You can also disable data-bearing actions while you review:
EXEC DBMS_CLOUD_AI.DISABLE_DATA_ACCESS;
-- SHOWSQL / EXPLAINSQL remain available (metadata-driven)
-- NARRATE and other data-bearing actions are blocked until re-enabled
EXEC DBMS_CLOUD_AI.ENABLE_DATA_ACCESS;
5. Same Flow from Python
- Install and connect:
import select_ai
select_ai.connect(user=user, password=password, dsn=dsn)
- Create or reuse a profile:
provider = select_ai.OCIGenAIProvider(
region="us-chicago-1",
oci_apiformat="GENERIC",
)
profile_attributes = select_ai.ProfileAttributes(
provider=provider,
credential_name="my_oci_ai_profile_key",
object_list=[
{"owner": "SH", "name": "CUSTOMERS"},
{"owner": "SH", "name": "SALES"},
{"owner": "SH", "name": "PRODUCTS"},
],
enforce_object_list=True,
)
profile = select_ai.Profile(
profile_name="oci_ai_profile",
attributes=profile_attributes,
description="Scoped profile for SH sales questions",
replace=True,
)
- Inspect, run, and narrate:
# Generate SQL without executing
sql = profile.show_sql(prompt="What are customer sales by product?")
print(sql)
# Generate, execute, return pandas DataFrame
df = profile.run_sql(prompt="What are customer sales last year by product and region?")
print(df.columns)
print(df)
# Optional: natural-language answer over the results
answer = profile.narrate(prompt="Summarize sales by region for last year")
print(answer)
- You can also instantiate an existing profile by name:
profile = select_ai.Profile(profile_name="oci_ai_profile")
df = profile.run_sql(prompt="How many promotions?")
Use show_sql heavily during development. Prefer run_sql / DataFrame for application code and narrate when the consumer is a business user.
6. What “Governed” Means in Practice
- Generated SQL runs as the database user. Roles, privileges, and VPD policies still apply.
- The object list limits the metadata the LLM sees. With enforce_object_list enabled, generation is constrained to the named objects.
- LLM credentials live in database credential objects, not in application prompts or tool arguments.
- Session tagging (DBMS_APPLICATION_INFO) and audit trails remain available so you can answer “what actually ran?”
- DISABLE_DATA_ACCESS lets you keep early experiments in a metadata-only lane.
This is the same posture that supports a live-business-data agent in the harness (Article 8): a controlled tool surface, scoped identity, and database-native evidence. Deeper multi-tenant isolation patterns are covered in Article 12.
7. Using Select AI as a Tool in an Agent Harness
Previous articles described the agent harness and its evals layer. A natural next tool is a narrow “ask_data” surface backed by Select AI:
- The tool accepts a natural-language question.
- The harness validates and authorizes the call.
- Select AI generates (and optionally runs) SQL under a pre-defined profile and object list.
- The observation returns structured results or a narrated answer.
- Traces and scores feed the evals layer.
This is safer than letting the model invent arbitrary SQL strings. The profile already encodes the allowed objects; the harness adds validation, logging, and stop conditions. Select AI also supports more advanced in-database agent capabilities; this article stays on the NL2SQL foundation that most teams need first.
Treat the golden set of natural-language questions as part of your evals suite (Article 9). Offline runs catch regressions before promotion; online sampling catches drift on real traffic.
8. Practical Tips and Pitfalls
- Start with a small, well-commented schema. Column comments and clear names improve generation quality.
- Always inspect with show_sql / SHOWSQL before enabling broad run_sql.
- Prefer narrate for business users; prefer run_sql / DataFrame for application code.
- Re-set the profile in each new session.
- Keep enforce_object_list enabled while the surface is young.
- Use DISABLE_DATA_ACCESS when you only need to review candidate SQL.
- Add natural-language questions to your golden dataset and score both the SQL shape and the final answer.
- Expand the object list deliberately; every added table increases the attack and error surface.
9. What You Can Do Next
- Expand the object list carefully as use cases prove themselves.
- Add RAG over trusted documents when answers need unstructured context (available in releases that include Oracle AI Vector Search).
- Wire the profile into an agent tool and evaluate it with the harness evals layer.
- Review multi-tenant isolation and deeper security patterns in the final articles of the series.
Most Asked Questions
Does Select AI send my data to the LLM?
By default, generation and inspection use schema metadata. Data-bearing actions (such as narrate) can send results when data access is enabled. Use DISABLE_DATA_ACCESS to keep early work metadata-only, and document the posture for your environment.
Can I use my own / private LLM endpoint?
Supported providers and models vary by platform and release. OpenAI-compatible and private endpoints are available in current documentation; configure them through the profile and credential.
How do I limit which tables the model can see?
Put only the intended objects in the profile’s object_list and enable enforce_object_list. Execution still respects database privileges and VPD.
What happens if the generated SQL is wrong?
Inspect with show_sql / explain_sql, adjust the prompt or the object list, and re-generate. Treat approved SQL as ordinary SQL under your normal review process.
SQL vs Python — which should I start with?
SQL developers can stay inside DBMS_CLOUD_AI and SELECT AI. Python developers get a clean client (select_ai) that returns DataFrames. Both paths use the same profiles.
How does this relate to agent memory and the harness?
Select AI is a natural tool surface for a live-business-data agent. The harness validates and logs the call; memory can store preferences or prior answers; evals measure whether the data tool still behaves correctly after changes.
Resources
- Select AI documentation
- Select AI capability matrix
- Select AI for Python (GitHub)
- Select AI for Python user guide
- Select AI by Release: A Quick Guide to 26ai and 19c Capabilities
- Safer NL2SQL with Select AI and AI Profiles
- The trust layer for enterprise AI on Oracle
- Article 8: Understanding Tool Calling and Agent Harnesses
- Article 9: How to Build the Evals Layer of Your Agent Harness
- Forward: Article 11 (MCP discovery path), Article 12 (multi-tenant security for agent memory and data access)
Hands-on
- Oracle LiveLabs: Get started with AI Agents using Select AI; Develop AI RAG Apps with Autonomous AI Database Select AI
- Oracle AI Developer Hub examples
Latest Release
- oracleagentmemory 26.8 on PyPI
- Oracle AI Agent Memory 26.8 documentation
- What’s New in Oracle AI Agent Memory: Graph-Aware Retrieval, Image Memory, and Enterprise Controls
Conclusion
Select AI gives agents and users a governed natural-language path to enterprise data without abandoning database security. Profiles, object lists, and inspectable actions keep the model inside a surface you control, while privileges, VPD, and auditing continue to apply to every statement that actually runs.
Once data access is in place, the remaining production questions are how you expose controlled tool surfaces to assistants and how multi-tenant isolation holds under real load, the subjects of the final articles in this series.
Try it yourself: Create an AI profile against a small set of tables in Oracle AI Database Free or FreeSQL, run show_sql on a natural-language question, inspect the generated statement, then execute with run_sql. Both the SQL interface and the Python select_ai package are documented with LiveLabs and Oracle AI Developer Hub examples you can follow today.