Use Semantic Context with Select AI

Select AI uses semantic context from external metadata sources to interpret business terminology when generating SQL from natural language or text-to-SQL. You can configure semantic sources to provide business definitions, metric calculations, table and column descriptions, and relationships that supplement database metadata.

For example, your organization can define an at-risk customer as a high-value customer who has not placed an order in the last 90 days and has an open support escalation. When you attach a source containing this definition to an AI profile, Select AI can use the definition to generate SQL for a request such as “Show me at-risk customers.”

About Semantic Context

Select AI augments natural-language prompts with metadata before sending the prompts to a large language model (LLM) for SQL generation. Semantic context supplements these inputs.

Existing metadata can include table names, column names and data types, table and column comments, constraints, annotations available with Oracle AI Database 26ai, and custom profile instructions. Semantic context adds business meaning to that metadata.

Select AI uses semantic context to interpret business terms when generating SQL. Database metadata describes the structure of your data. Semantic context supplies the business definitions needed to interpret a request.

For example, a numeric spending column does not establish which customers your organization considers high-value. A business definition supplies that meaning.

Semantic Sources and Semantic Context

A semantic source provides the configuration that Select AI uses to access business information.

Semantic context is the information that the source returns.

Creating a source stores a configuration that Select AI uses to retrieve business context; it does not retrieve the configuration itself. Semantic context enriches only the database objects already available to the active AI profile and does not override the requesting user’s privileges on those objects.

The following are the supported semantic sources:

Source type Purpose Example
catalog Retrieves metadata from a supported catalog provider. A catalog source returns table descriptions and business glossary definitions.
custom Calls customer-provided PL/SQL functions. A custom callback returns definitions that your application maintains.
file Retrieves relevant context from a configured file. A file source returns relevant business information from a configured file.
mcp Calls configured tools on an MCP-compatible server. An MCP source calls configured tools to retrieve business information.

A source can contribute object context, global context, or all:

How Semantic Context Interacts with Select AI

Select AI processes semantic context as part of its existing prompt and SQL-generation flow:

  1. Select AI reads the active AI profile and identifies its attached semantic sources.

  2. Select AI identifies candidate database objects from the profile’s object list or automated object-selection index.

  3. Select AI verifies that the requesting user can access those objects.

  4. Select AI obtains object and global context according to each source’s configured scope.

  5. Select AI normalizes the context into terms, definitions, and associated database objects.

  6. Select AI combines the semantic context with database metadata, comments, annotations, and profile instructions.

  7. The configured language model uses the combined information to generate SQL.

Semantic context does not add database objects to the active profile and does not bypass database privileges.

Interaction with Select AI Capabilities

Select AI capability Interaction with semantic context
object_list Select AI uses information only about the database objects listed in the profile’s object list.
Automated object selection Select AI adds useful information about database objects while building its index. When you ask a question, it uses the objects chosen from that index.
enforce_object_list Semantic context does not add objects to the profile’s object list.
Table and column comments Semantic context adds to existing table and column descriptions. It does not replace them.
role and additional_instructions Select AI follows the profile’s existing instructions as well as the semantic context.
Multiple semantic sources Select AI combines information from every enabled semantic source connected to the active profile. The order of source names in the semantic_source array does not define precedence. If two sources provide different definitions for the same term, both definitions can appear in the prompt. If an enabled source is unavailable or returns an error, semantic-context retrieval fails and the Select AI request fails. For source-specific request and response requirements, see Semantic Source Attributes.
SHOWCONTEXT Select AI shows the normalized semantic context included in the configured model prompt for the request.
SHOWPROMPT Select AI shows the complete prompt it used, including semantic information, database details, and profile instructions.
SHOWSQL Select AI creates SQL after adding the relevant semantic information to the prompt.
SELECT AI Select AI creates and runs the SQL according to the configured settings and profile.

Semantic Source Scope

The scope attribute determines which type of context a semantic source contributes. See Common Attributes for more details.

Supported Scope Description Includes
object Select AI requests context for database objects selected for the natural-language request. Select AI filters inaccessible objects before checking the cache or sending object identifiers to an external semantic provider. Table descriptions
Column descriptions
Metric definitions associated with a table, including the business meaning and calculation of a measurable value
Object-specific business rules
Business names for physical database objects
global Select AI requests business context related to the user’s natural-language request. Select AI obtains global context for each request and does not cache global context. Glossary terms
Business definitions
Domain terminology
General business rules
Metric definitions that do not belong to a single database object
Note: File semantic sources support only global scope. They do not support object or all scope. For the scopes supported by each source type, see Common Attributes.
all A source contributes both object and global context. The source must provide the configuration required for both paths. A source can return an empty result for either path; a valid empty result does not cause the Select AI request to fail. Custom source: object_callback_func and global_callback_func
MCP source: object_tool and global_tool
Catalog source: attributes required for object retrieval, including data_source_name

See Also:

Prerequisites for Using Semantic Context with Select AI

Complete the following prerequisites before using semantic context with Select AI:

How to Use Semantic Context with Select AI

The following steps guide you to create and use semantic context with Select AI:

  1. Create a semantic source. See CREATE_SEMANTIC_SOURCE Procedure for more information.
  2. Attach the semantic sources to a Select AI profile. See semantic_source in Profile Attributes for more information.
  3. Set the profile for the session. See SET_PROFILE Procedure for more information.
  4. Inspect the context used for a prompt using showcontext as a Select AI action. See Use AI Keyword to Enter Prompts and Example: Select AI Actions for more information.
  5. Use natural language prompts to query the data.
  6. (Optional) Query DBMS_AI_SEMANTIC Views for information about the USER_, ALL_, and DBA_ semantic-source views. See DBMS_AI_SEMANTIC Views for more information.

For an end-to-end example covering supported semantic sources, see Example: Use Semantic Context with Select AI.

Use Cases for Semantic Context

Use semantic context to supplement database metadata with business information when generating SQL from natural-language questions. The following use cases illustrate how you can apply semantic context with Select AI.

Benefits of Using Semantic Context

Semantic context provides the following benefits when you use Select AI: