The evolution of databases has reached a fascinating point where traditional data storage now blends seamlessly with artificial intelligence. Oracle 26 AI Database is a strong example of this shift, bringing vector search and embedding-based intelligence directly into the database layer.
![]() |
| Running AI Models within Oracle Database |
Before any semantic search, similarity matching, or AI-driven querying can happen, a crucial groundwork must be laid. This article walks through that foundation step by step — from configuring Oracle directories to downloading an ONNX embedding model that the database can later use for vector generation.
This setup is not complex, but it must be done correctly. Think of it as preparing the soil before planting the seeds of AI.
Why ONNX Models Matter in Oracle 26 AI DB
ONNX (Open Neural Network Exchange) is a standardized format for machine learning models. By supporting ONNX, Oracle allows pretrained models — such as sentence embedding models — to be executed close to the data.
This means:
- No external vector database dependency
- No constant back-and-forth between application and AI services
- Faster, more secure semantic queries
However, the database needs a secure and accessible location to store these models. That’s where directory objects and filesystem preparation come into play.
![]() |
| Vectorization Flow |
Step 1: Connecting to the Oracle Database
We begin by connecting to the Oracle 26 AI Database using a privileged account. This is required because directory objects are database-level resources.
sql system/YourPassword123@//localhost:1521/FREEPDB1
Once connected, we can define where the database is allowed to read and write model files.
Step 2: Creating a Directory for Vector Models
Oracle does not allow direct access to filesystem paths. Instead, it uses directory objects as controlled entry points.
Here, we create a directory named VECTOR_MODELS that maps to a location inside the container filesystem.
CREATE OR REPLACE DIRECTORY VECTOR_MODELS AS '/tmp/vector_models';
This statement does not create the physical folder. It only tells Oracle, “If you need models, look here.”
Step 3: Granting Access to the Application Schema
Security is a core principle in Oracle. Even after creating the directory, no schema can access it unless explicitly allowed.
Grant read and write permissions to the schema that will later perform embedding operations.
GRANT READ, WRITE ON DIRECTORY VECTOR_MODELS TO demo_schema;
This ensures controlled access while still enabling AI workflows.
Step 4: Entering the Oracle Database Container
Since Oracle 26ai DB is running inside Docker, the filesystem changes must be done within the container.
First, access the container shell:
docker exec -it oracle26ai-free bash
Then switch to the Oracle user to ensure correct permissions:
su - oracle
Step 5: Creating the Physical Model Directory
Now we create the actual directory that the database object points to. This step is critical — without it, Oracle will know the path but find nothing there.
mkdir -p /tmp/vector_models
Navigate into the directory:
cd /tmp/vector_models
Step 6: Downloading the ONNX Embedding Model
With everything in place, we now download a pretrained embedding model. The MiniLM-based ONNX model is lightweight, efficient, and well-suited for semantic search.
curl -o all_MiniLM_L12_v2.onnx "https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/eLddQappgBJ7jNi6Guz9m9LOtYe2u8LWY19GfgU8flFK4N9YgP4kTlrE9Px3pE12/n/adwc4pm/b/OML-Resources/o/all_MiniLM_L12_v2.onnx"
Once downloaded, the model becomes immediately available to Oracle through the directory object.
What Happens Next?
At this stage, the environment is fully prepared:
- The database knows where models live
- The filesystem is aligned with Oracle permissions
- The ONNX model is ready for use
From here onward, the remaining tasks — model registration, embedding generation, vector storage, and similarity queries — can be automated or orchestrated through AI agents.
This is where you can ask your Claude MCP to do the rest. A prompt like below is enough to get a good demo:
I need help with Oracle Database 26ai vector embeddings and ONNX models.
Connection: local_apex (connects to demo_schema on //localhost:1521/FREEPDB1)
Setup completed:
- Database directory: VECTOR_MODELS created and points to /tmp/vector_models/
- ONNX model file: all_MiniLM_L12_v2.onnx downloaded to /tmp/vector_models/ (384 dimensions)
- Oracle version: 23.26.0.0.0
- User: demo_schema with DB_DEVELOPER_ROLE
What I need:
1. Connect to local_apex
2. Load the ONNX model (all_MiniLM_L12_v2.onnx) from VECTOR_MODELS directory into the database
3. Create an animals table with columns: animal_id, animal_name, family, description, and embedding (VECTOR 384 dimensions)
4. Insert 10 sample animals (5 from dog family Canidae, 5 from cat family Felidae) with descriptions
5. Generate real vector embeddings from the descriptions using the loaded ONNX model
6. Show me semantic search queries that demonstrate finding similar animals
Please help me complete this setup and test vector similarity search.
Possible Issues and fix
1. Tablespace quota errors
This can be increased by extending the tablespace of given schema using below SQL Query (to be executed by DBA as it requires sys access)
ALTER USER demo_schema QUOTA UNLIMITED ON APEX_6876247124458041;
2. Auto-extend disabled issues
This could be fixed by extending the data file. First, to locate it, the following SQL would help:
SELECT file_name, ROUND(bytes/1024/1024) AS size_mb, autoextensible FROM dba_data_files;
Now, to extend it, execute below SQL query. Remember to replace the file path with your actual file path:
ALTER DATABASE DATAFILE '/opt/oracle/oradata/FREE/FREEPDB1/APEX_6876247124458041.dbf' AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED;
Conclusion
AI inside the database is no longer a futuristic idea — it’s a practical engineering approach. By setting up ONNX models correctly, Oracle 26ai Database transforms into a powerful semantic engine capable of understanding meaning, not just data.
This foundation opens the door to vector search, RAG architectures, intelligent APEX applications, and beyond — all without leaving the Oracle ecosystem.
In upcoming articles, we’ll move from setup to execution, showing how embeddings are generated and queried directly from SQL.
data:post.title
Written by
Published on January 10, 2026




No comments: