Amazon RDS for Oracle 26ai integrates with Amazon Bedrock through Oracle's DBMS_CLOUD_AI package and the Select AI feature. You can ask questions of your data in natural language and let a Bedrock foundation model generate and run the SQL — no data leaves your database. In this post we configure the integration and run each Select AI action from SQL*Plus (SQLcl works identically), and we share a practical tip about choosing a Bedrock model.
References:
Solution overview
- Provide network connectivity from the DB instance to the Bedrock runtime endpoint.
- Grant Bedrock permissions to an IAM identity and create AWS access keys.
- Grant database privileges and a network ACE for the Bedrock endpoint.
- Create an AWS credential and a Select AI AI profile.
- Run Select AI actions:
chat,showsql,runsql,narrate, andGENERATE.
Prerequisites
- An Amazon RDS for Oracle DB instance running Oracle Database 26ai (engine
oracle-ee-cdb, an26.0.0.0engine version). - Amazon Bedrock model access enabled for the model you plan to use.
- A SQL client (SQL*Plus or SQLcl) that can reach the DB endpoint on 1521.
Placeholders used below:
| Placeholder | Meaning |
|---|---|
<db-endpoint> / <pdb-service> | RDS endpoint host / PDB service name |
<admin-user> / <admin-password> | RDS master user and password |
<db-user> / <db-password> / <db-role> | least-privilege user / password / role |
<region> | AWS Region, e.g. us-east-1 |
<access-key-id> / <secret-access-key> | IAM access key for the credential |
<model-id> | Bedrock model id (see "Choosing a model") |
Step 1: Network connectivity to Bedrock
The DB instance must reach bedrock-runtime.<region>.amazonaws.com on port 443, via either:
- Option 1 (recommended): a VPC interface endpoint (AWS PrivateLink) for
com.amazonaws.<region>.bedrock-runtime, with Private DNS enabled and a security group allowing 443 from the DB security group. Traffic stays on the AWS network. - Option 2: a NAT gateway — the DB subnet routes
0.0.0.0/0to a NAT gateway in a public subnet, and the DB security group allows outbound 443.
Either option works. Confirm the DB subnet route table has a route to the Bedrock endpoint before continuing.
Step 2: IAM permissions and access keys
Attach a policy allowing model invocation to the IAM user (or role) whose keys you will store in the database:
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "BedrockInvoke",
"Effect": "Allow",
"Action": ["bedrock:InvokeModel","bedrock:InvokeModelWithResponseStream"],
"Resource": [
"arn:aws:bedrock:<region>::foundation-model/*",
"arn:aws:bedrock:<region>:<account-id>:inference-profile/*"
]
}]
}
Generate an access key ID and secret access key for that identity, and make sure the model is enabled in Bedrock console → Model access.
Step 3: Database privileges and network ACE
As the master user in the PDB:
GRANT EXECUTE ON DBMS_CLOUD TO <db-role>;
GRANT EXECUTE ON DBMS_CLOUD_AI TO <db-role>;
GRANT <db-role> TO <db-user>;
-- Grant the Bedrock host ACE DIRECTLY to the user.
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'bedrock-runtime.<region>.amazonaws.com',
ace => xs$ace_type(
privilege_list => xs$name_list('http'),
principal_name => UPPER('<db-user>'),
principal_type => xs_acl.ptype_db));
END;
/
Tip: grant the Bedrock host ACE to the user, not to a role.
DBMS_CLOUD_AInetwork calls are not authorized through role-granted ACEs, so a role-only ACE results inORA-24247: Network access denied by access control list (ACL).
Step 4: Create the credential and AI profile
Connect as the application user:
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'AWS_BEDROCK_CRED',
username => '<access-key-id>',
password => '<secret-access-key>');
END;
/
BEGIN
DBMS_CLOUD_AI.CREATE_PROFILE(
profile_name => 'BEDROCK_PROFILE',
attributes => '{"provider":"aws",
"credential_name":"AWS_BEDROCK_CRED",
"model":"<model-id>",
"object_list":[{"owner":"<db-user>","name":"EMP"}]}');
END;
/
BEGIN DBMS_CLOUD_AI.SET_PROFILE('BEDROCK_PROFILE'); END;
/
SELECT DBMS_CLOUD_AI.GET_PROFILE() FROM dual;
For a Bedrock endpoint in a Region other than us-east-1, add "region":"<region>" and "target_language":"english" to the profile attributes (both are required together due to a documented DBMS_CLOUD_AI limitation).
Sample data used in the examples:
CREATE TABLE emp (id int primary key, name varchar2(20), salary int, last_join date);
INSERT INTO emp VALUES(1,'Alice',1000, DATE '2000-01-01');
INSERT INTO emp VALUES(2,'Bob', 2000, DATE '2001-01-01');
INSERT INTO emp VALUES(3,'Carol',3000, DATE '2002-01-01');
COMMIT;
Step 5: Use Select AI
chat — free-form
SELECT AI chat what is Amazon Bedrock in one sentence;
Amazon Bedrock is a managed service by Amazon Web Services designed to help
developers build, share, and scale generative AI applications.
showsql — natural language to SQL
SELECT AI showsql how many employees are there and what is the total salary;
SELECT COUNT("ID") AS "Number_of_Employees",
SUM("SALARY") AS "Total_Salary"
FROM "<DB-USER>"."EMP"
runsql — generate and run (default action)
SELECT AI runsql how many employees are there;
Total_Employees
---------------
3
narrate — natural-language answer
SELECT AI narrate what is the average salary of employees;
The average salary of employees in the "EMP" table is 2000.
GENERATE — function form (for APEX / stateless tools)
SELECT DBMS_CLOUD_AI.GENERATE(
prompt => 'list employees earning more than 1500',
profile_name => 'BEDROCK_PROFILE',
action => 'showsql') AS response
FROM dual;
SELECT "EMP"."ID", "EMP"."NAME", "EMP"."SALARY"
FROM "<DB-USER>"."EMP" "EMP"
WHERE "EMP"."SALARY" > 1500
Choosing a model
You must set the model attribute explicitly; there is no default for the AWS provider. Select AI's SQL-generation actions call the Bedrock Converse API.
- Recommended: a model that supports on-demand throughput / direct invocation, such as Amazon Nova Lite (
amazon.nova-lite-v1:0) or Nova Pro. In our testing, Nova Lite worked for every Select AI action. - Refer to AWS documentation on other models supported.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
ORA-24247: Network access denied by ACL | Grant the Bedrock host ACE to the user (not just a role); confirm the host/Region string. |
ORA-20403: Authorization failed for URI … /converse | Model/endpoint authorization for the Converse API. Prefer an on-demand model; verify Bedrock model access and the inference-profile path. |
| Timeouts reaching the endpoint | Network path missing — add a VPC interface endpoint or NAT route and allow outbound 443. |
ORA-20000: Data access is disabled for SELECT AI | An admin ran DBMS_CLOUD_AI.DISABLE_DATA_ACCESS; re-enable with ENABLE_DATA_ACCESS. |
Clean up
Drop the AI profile and credential, and delete the DB instance, IAM keys, and any VPC endpoint you created for the test.
Conclusion
With Oracle Database 26ai on Amazon RDS, DBMS_CLOUD_AI and Select AI turn natural language into SQL against your own tables using Amazon Bedrock models — configured with a credential, a network ACE, and an AI profile. Grant the Bedrock ACE to the invoking user, and choose a model that supports on-demand invocation for the Select AI SQL actions. For loading and querying Amazon S3 data from the same instance, see the companion post on the DBMS_CLOUD package.
No comments:
Post a Comment