Use AI Keyword to Enter Prompts

Use AI as the keyword in a SELECT statement for interacting with the database using natural language prompts.

The AI keyword in a SELECT statement instructs the SQL execution engine to use the LLM identified in the active AI profile to process natural language and to generate SQL.

You can use the AI keyword in a query with Oracle clients such as SQL Developer, OML Notebooks, and third-party tools, to interact with database in natural language.

Note: You cannot run PL/SQL statements, DDL statements, or DML statements using the AI keyword.

Syntax

The syntax for running AI prompt is:

SELECT AI `action` `natural_language_prompt`

Parameters

The following are the parameters available for the action parameter:

Parameter Description
runsql Runs the underlying SQL command for the natural language prompt and supports retrieval-augmented generation (RAG). This is the default action and does not require specifying this parameter.
showsql Displays the SQL statement for a natural language prompt.
explainsql Explains the generated SQL from the prompt in a natural language. This option sends the generated SQL to the AI provider to produce a natural language explanation.
narrate

The narrate action supports both natural language to SQL (NL2SQL) and RAG.

For NL2SQL, narrate sends the result of a SQL query run by the database to the LLM, which generates a natural language description of that result.

For RAG, when the AI profile includes a vector index, the system uses the specified transformer (or default transformer) model to create a vector embedding from the prompt for semantic similarity search against the vector store. The system then adds the retrieved content from the vector store to the user prompt and sends it to the LLM to generate a response based on this information.

If you do not want table data or vector search documents to be sent to an LLM, a user with administrator privileges can disable such access for all users of the given database. This, in effect, disables the narrate action.

chat

Passes the user prompt directly to the LLM to generate a response, which is provided to the user.

For session-based short-term conversations, if conversation in the DBMS_CLOUD_AI.CREATE_PROFILE function is set to true, this option includes content from prior interactions or prompts, potentially including schema metadata.

For multiple named conversations, only the chat-related prompt histories are sent to the LLM. See Select AI Conversations to learn more..

showprompt

This action supports NL2SQL and RAG. This action does not support synthetic data generation, explainsql, and narrate.

Display the constructed prompt that would be sent to the generative AI model.

summarize

Generates a summary of the content for your text and large files using user-specified AI providers. If your AI profile is set in the session then, you can use SELECT AI SUMMARIZE .

See Generate a Summary with Select AI and Example: Select AI Actions to learn more.

If you want to customize the summary generation, use the DBMS_CLOUD_AI.SUMMARIZE function. See Example: Select AI Summarize to learn more.

feedback

Enables you to provide feedback in natural language to improve the LLM's ability to generate more accurate SQL queries. You can use it alongside with the other Select AI's actions such as runsql, showsql, and explainsql. See Feedback to learn more.

Note:

This feature is available only on Oracle AI Database 26ai. If you are using narrate, ensure that the profile is configured for SQL generation and not RAG.
translate Enables you to use generative AI from the OCI translation service to translate your prompt into the preferred language specified as the target_language attribute in your AI profile.
agent Calls the agent team to process the natural language prompt. See Select AI Agent and Examples of Using Select AI Agent for more details.

To learn how you can use these actions, see Examples of Using Select AI.

Usage Notes