You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Select AI Inspect - Database Inspection Tool Built Using Select AI Agent (26ai)
1
+
# Select AI Inspect - Database Inspection Tool Built Using Select AI Agent
2
2
3
3
## Overview
4
4
@@ -11,7 +11,7 @@ For definitions of **Tool**, **Task**, **Agent**, and **Agent Team**, see the to
11
11
12
12
Instead of manually reviewing tables, searching through PL/SQL files, or examining function and procedure metadata, users can simply ask the Select AI Inspect agent natural language questions such as:
13
13
14
-
*How are these tables related?
14
+
*Which objects reference this table?
15
15
* Why am I receiving this error from a function call?
16
16
* What is this function used for?
17
17
* What objects will be impacted if I modify this package?
@@ -36,6 +36,7 @@ Select AI Inspect supports the following database object types:
36
36
* Tables
37
37
* Views
38
38
* Types
39
+
* Type Bodies
39
40
* Triggers
40
41
* Functions
41
42
* Procedures
@@ -49,10 +50,12 @@ Users may define the inspection scope either at the individual object level or a
49
50
50
51
## Prerequisites
51
52
52
-
- Oracle Database 26ai (Autonomous AI Database supported)
53
+
- Oracle Autonomous AI Database (26ai)
53
54
- Select AI and `DBMS_CLOUD_AI_AGENT` enabled
54
55
-`ADMIN` or equivalent privileged user for installation
55
56
- A Select AI profile created with `DBMS_CLOUD_AI.CREATE_PROFILE`
57
+
- The Select AI profile used for inspection must include an `embedding_model` attribute
58
+
- If the Select AI profile uses an OCI Generative AI model/provider, it must also include `oci_compartment_id`
56
59
57
60
---
58
61
@@ -64,7 +67,7 @@ Before running installation commands:
64
67
2. Open a terminal and change directory to `autonomous-ai-agents/database_inspect`.
65
68
3. Choose one execution mode:
66
69
- SQL*Plus/SQLcl: run script files directly with `@script_name`.
67
-
- SQL Worksheet (Database Actions or other SQL IDE): open the `.sql`file and run/paste its contents.
70
+
- SQL Developer or another SQL IDE: run the file in script mode so interactive prompts are shown.
68
71
4. Uploading scripts to `DATA_PUMP_DIR` is not required for these methods.
You can also execute the contents of `database_inspect_tool.sql` and `database_inspect_agent.sql` in SQL Worksheet.
80
+
`database_inspect_agent.sql` uses interactive prompts, so run it as a script instead of copy/pasting individual statements into a worksheet.
81
+
82
+
### Step 1: Install `DATABASE_INSPECT` Package and Tool Framework
83
+
84
+
Run `database_inspect_tool.sql` first.
85
+
86
+
The script prompts for:
87
+
88
+
-`SCHEMA_NAME`: target schema where `DATABASE_INSPECT` is compiled
89
+
90
+
What the tools installer does:
91
+
92
+
- Grants required execute privileges to the target schema
93
+
- Switches `CURRENT_SCHEMA` to the target schema
94
+
- Compiles the `DATABASE_INSPECT` package specification and body inline
95
+
- Is safe to rerun
96
+
97
+
Notes:
98
+
99
+
- The tools installer no longer executes `DATABASE_INSPECT.setup` directly from an `ADMIN` anonymous block. This avoids `ORA-06598` when the package is `AUTHID CURRENT_USER`.
100
+
- Internal `DATABASE_INSPECT` tables are initialized from the target-schema execution path when the package is invoked by the agent installer or by direct package usage in the target schema.
101
+
102
+
### Step 2: Create or Recreate the Inspect Agent Team
103
+
104
+
Run `database_inspect_agent.sql` after the package is installed.
105
+
106
+
The script prompts for:
107
+
108
+
-`INSTALL_SCHEMA_NAME`: schema where the team is created
109
+
-`AI_PROFILE_NAME`: profile used for reasoning and embeddings
110
+
-`AGENT_TEAM_NAME`: team name to create
111
+
-`RECREATE_EXISTING`: `Y` to drop and recreate an existing team, otherwise `N`
112
+
-`SCOPE_MODE`: guided scope mode; supported values are `SCHEMA`, `TABLE`, `PACKAGE`, and `JSON`
113
+
-`SCOPE_OWNERS`: use this for `SCHEMA` mode; enter one or more schema owners separated by commas, or leave blank to use `INSTALL_SCHEMA_NAME`
114
+
-`OBJECT_OWNER`: use this for `TABLE` or `PACKAGE` mode; enter the owner/schema of the listed objects, or leave blank to use `INSTALL_SCHEMA_NAME`
115
+
-`OBJECT_NAMES`: use this for `TABLE` or `PACKAGE` mode; enter one or more object names separated by commas
116
+
-`MATCH_LIMIT`: optional
117
+
-`TEAM_ATTRIBUTES_JSON`: use this for `JSON` mode
118
+
119
+
The script now shows one simple input section for these values. Enter only the fields that apply to the selected `SCOPE_MODE` and leave the others blank.
120
+
121
+
Guided input examples:
122
+
123
+
- Single schema scope:
124
+
`SCOPE_MODE = SCHEMA`
125
+
`SCOPE_OWNERS = <INSTALL_SCHEMA_NAME>`
126
+
- Multiple schema owners:
127
+
`SCOPE_MODE = SCHEMA`
128
+
`SCOPE_OWNERS = SH,HR`
129
+
- Multiple tables in one schema:
130
+
`SCOPE_MODE = TABLE`
131
+
`OBJECT_OWNER = SH`
132
+
`OBJECT_NAMES = SALES,CUSTOMERS,PRODUCTS`
133
+
- Multiple packages in one schema:
134
+
`SCOPE_MODE = PACKAGE`
135
+
`OBJECT_OWNER = HR`
136
+
`OBJECT_NAMES = EMP_PKG,PAYROLL_PKG`
137
+
138
+
Advanced `TEAM_ATTRIBUTES_JSON` example for JSON mode:
139
+
140
+
```json
141
+
{"object_list":[
142
+
{"owner":"SH","type":"TABLE","name":"SALES"},
143
+
{"owner":"SH","type":"TABLE","name":"CUSTOMERS"},
144
+
{"owner":"SH","type":"TABLE","name":"PRODUCTS"}
145
+
]}
146
+
```
147
+
148
+
What the agent installer does:
149
+
150
+
- Grants required privileges for agent creation and background jobs, including `CREATE JOB`, `CREATE SEQUENCE`, `CREATE PROCEDURE`, and `CREATE VIEW`
151
+
- Creates `DATABASE_INSPECT_AGENT_JOB_LOG$` in the target schema
152
+
- Creates submitter and worker procedures in the target schema
153
+
- Validates that `AI_PROFILE_NAME` has a non-null `embedding_model`
154
+
- Requires `AI_PROFILE_NAME` to include `oci_compartment_id` when the profile uses an OCI Generative AI model/provider
155
+
- Enforces `AI_PROFILE_NAME` as `profile_name`, even if `TEAM_ATTRIBUTES_JSON` includes a different value
156
+
- Converts common installation failures into user-friendly log messages, including missing OCI compartment id, tablespace quota errors, and embedding-dimension mismatch errors
157
+
- Verifies that the expected agent tools were recreated successfully
158
+
159
+
`RECREATE_EXISTING = Y` behavior:
160
+
161
+
- Cleans up any existing Select AI team, agent, and task objects for the requested team name
162
+
- Drops the existing team metadata and vectorized object state
163
+
- Recreates the team using the resolved attributes
164
+
165
+
### Monitoring Background Installation
166
+
167
+
Each submission writes one row to `DATABASE_INSPECT_AGENT_JOB_LOG$`.
| profile_name | AI profile name for the agent team. If provided, the exisiting profile_name value will be overwritten. If a different AI provider is specified, the `object_list` will be re-vectorized due to embedding dimension mismatches. | N ||
298
+
| profile_name | AI profile name for the agent team. If provided, the exisiting profile_name value will be overwritten. Any profile change triggers re-vectorization of the `object_list`, because embedding dimensions or similarity semantics can change even within the same provider.| N ||
203
299
| object_list | List of database objects the agent team is allowed to inspect.<br />Support "owner", "type" and optional "name" for the object. if "name" is not provided, we will set all objects in the schema.<br />If provided, the original object_list will be removed and the new object_list will be vectorized. | N | e.g.<br />'[{"owner":"DEMO", "type":"schema"}]'<br />'[{"owner":"DEMO", "type":"package body", "name":"CHECKOUT_PKG"}]' |
204
300
| match_limit | Specifies the maximum number of results to return in a hybrid/vector search query from RETRIEVE_OBJECT_METADATA agent tool. | N | default value is 10 |
205
301
206
-
207
302
---
208
303
209
304
## Agent Setup
210
305
211
-
An inspection agent is created when you call`DATABASE_INSPECT.create_inspect_agent_team`.
306
+
An inspection agent can be created directly by calling`DATABASE_INSPECT.create_inspect_agent_team`, but the recommended installation path is to use `database_inspect_agent.sql` so that setup, validation, logging, and background execution are handled for you.
212
307
213
308
### Supported Tools
214
309
215
310
***list_objects**: List all available objects for the agent
216
311
***list_incoming_dependencies**: List objects that depend on or reference the given object
217
312
***list_outgoing_dependencies**: List objects that the given object itself depends on or references
218
-
***generate_graph**: Generate relationship visualizations as Mermaid graph syntax or HTML/CSS tree markup (dependency, hierarchy, binary-tree style, network)
219
313
***retrieve_object_metadata**: Retrieve the full metadata for the given object
220
314
***retrieve_object_metadata_chunks**: Retrieve a list of metadata chunks by performing hybrid search (vector search + Oracle Text search) to answer user’s query
221
315
***expand_object_metadata_chunk**: Given a selected result from the retrieve_object_metadata_chunks tool, returns an expanded metadata segment around the specified chunk to provide additional context
@@ -238,14 +332,15 @@ This schema includes more than 10 tables, such as customers, products, orders, a
238
332
4. Explain what the CHECKOUT_PKG.reprice_order procedure is used for, including its purpose, parameters and business rules.
239
333
5. Can you write and run a test script for the calc_tax_amount function to verify the results and check for any bugs?
240
334
6. When I call the calc_tax_amount function, for state_code = 'CA' (rate 0.0825), calc_tax_amount(10.01, 'CA') returns 0.82, but it should return 0.83. Please debug the function and show me the exact code that needs to be fixed.
241
-
7. Please show me a dependency graph for my table relationships.
242
-
8. Show the object call hierarchy as a binary-tree style diagram.
243
-
9. Render the outgoing dependency hierarchy as HTML + CSS tree markup for my web app.
335
+
7. Summarize the CHECKOUT_PKG package body in one paragraph.
336
+
8. Generate PLDoc comments for the calc_tax_amount function.
337
+
9. Which packages and procedures will be impacted if I modify the ORDERS table?
338
+
10.Get me a list of tables available for inspection.
0 commit comments