Agentic AI Foundations Series · Part 6 of 6
Part 6: Oracle AI Database – The Agent's Memory
Oracle AI Database stores vectors right next to your tables, JSON, and graphs. An agent can search by meaning and run SQL in one place, under the security you already manage. For a DBA, this is home ground.
What is a vector, really?
An embedding is a list of numbers that captures meaning. "Tablespace full" and "no space left in datafile" use different words but land close together. "Listener down" lands far away. Searching by closeness = semantic search.
The new SQL pieces
- VECTOR data type – a column for embeddings, e.g.
VECTOR(768, FLOAT32). - VECTOR_EMBEDDING() – creates embeddings inside the database using an ONNX model you load with
DBMS_VECTOR.LOAD_ONNX_MODEL. You can also call external models such as OCI Generative AI. - DBMS_VECTOR_CHAIN – the pipeline helpers:
UTL_TO_TEXT(extract),UTL_TO_CHUNKS(split),UTL_TO_EMBEDDINGS(embed). - VECTOR_DISTANCE() – measures closeness. Order by it and fetch the top rows:
SELECT doc_id, chunk_text
FROM runbook_chunks
ORDER BY VECTOR_DISTANCE(embedding, :q_vec, COSINE)
FETCH FIRST 5 ROWS ONLY;
Distance metrics: COSINE (most common for text), EUCLIDEAN, DOT, MANHATTAN, and HAMMING/JACCARD for binary vectors.
Vector indexes: think B-tree vs bitmap
Just as you choose index types for workloads, you choose vector indexes:
- HNSW – an in-memory graph of neighbors. Fastest and very accurate. Needs the vector memory pool (
VECTOR_MEMORY_SIZE). - IVF – groups vectors into partitions on disk. Scales to huge data with less memory.
Exact search compares every vector: 100% accurate, slower. Approximate search uses the index: FETCH APPROX FIRST 5 ROWS ONLY WITH TARGET ACCURACY 90.
RAG in eight steps
Be ready to put these in order:
- Load documents
- Chunk them
- Embed the chunks
- Store in a VECTOR column and index it
- Embed the user's question
- Similarity search for the top-k chunks
- Send question + chunks to the LLM
- Return a grounded answer with sources
Select AI: talk to your data in English
- Package DBMS_CLOUD_AI; you create an AI profile (provider, credential, model, allowed tables).
- Actions:
runsql(default, runs it),showsql(shows SQL only),explainsql,narrate(answer in plain language),chat. - Select AI with RAG adds vector search over your documents; Select AI Agent builds agents with tools inside the database.
Why keep the agent's memory in the database?
One source of truth, transactional consistency, and your existing privileges, VPD, and auditing apply to every agent query. No separate vector store to sync.
Remember for the exam
- VECTOR type, VECTOR_EMBEDDING, VECTOR_DISTANCE; COSINE is the usual metric.
- HNSW in memory, IVF partitioned; approximate = index, exact = full compare.
- Select AI = DBMS_CLOUD_AI + AI profile; showsql shows without running.
Self-check
- Which vector index lives in memory? (HNSW)
- Which Select AI action shows the generated SQL without running it? (showsql)
- In RAG, what happens right after chunking? (Embedding the chunks)
No comments:
Post a Comment