Run Natural Language Query in the Data Analysis Tool
You can query the Oracle Autonomous Database by using Natural Language Query rather than having to write SQL Query.
Prerequisites
- An OpenAI, or Cohere or An Azure OpenAI account service with credit
- An access to
DBMS_CLOUD_AI
package.
- You must set your AI profile using the Natural Language Query feature. Follow the steps mentioned in this chapter to Use Select AI to Generate SQL from Natural Language Prompts.
- After you have created and configured your AI profile, set your AI profile in Data Studio Preferences wizard on the Connections page to use AI features such as generating SQL from Natural Language in the Data Studio tool.
- Generate SQL Queries From Natural Language on Analytic Views
You can create SQL queries on Analytic Views.
- Generate SQL Queries From Natural Language on Tables
You can create SQL queries on Tables.
- Generate SQL Queries From Natural Language on Analytic Views
To run a natural language query from SQL query on Analytic Views, perform the following steps: - Generate SQL Queries from Natural Language on Tables
Follow the procedure mentioned below to generate SQL queries from Natural Language on Tables:
Parent topic: The Data Analysis Tool
Generate SQL Queries From Natural Language on Analytic Views
To run a natural language query from SQL query on Analytic Views, perform the following steps:
Let's say you wish to view sales amount in a categorized way.
- On the Data Analysis home page, click on any of the Analytic Views you wish to query.
In this example, you will query the
SH_SALES_HISTORY
Analytic View.This opens the Analyses page.
- Select Natural Language. Selecting Natural Language opens the SQL worksheet area with a predefined SQL query on the worksheet area. Note
You can view Natural Language option only after you have configured and set AI profile using the Use Select AI to Generate SQL from Natural Language Prompts procedure and set the Data Studio Settings wizard on the Connections page. - Enter the following natural Query you wish to run on
SH_SALES_HISTORY
in the Natural Query field:show me amount sold by category
. - Click Generate Query.
-
After the tool generates the query, the Query Result tab displays the result of the query. You can also view the graphical representation of the contents of the
PLAN_TABLE
in the Explain Plan tab.You can alternatively view the query result in chart view by switching the display mode in Chart View or Diagram View.
Parent topic: Run Natural Language Query in the Data Analysis Tool
Generate SQL Queries from Natural Language on Tables
Follow the procedure mentioned below to generate SQL queries from Natural Language on Tables:
-
On the Data Analysis home page, click on any of the Tables you wish to query. In this example, we select the
PRODUCTS
table.This opens the Analyses page with a query that retrieves all the columns from the selected table
PRODUCTS
. - Select Use Natural Query.
- Selecting Use Natural Query lets you select multiple tables from the Select Tables icon.
Note
You can view Natural Language option only after you have configured and set AI profile using the Use Select AI to Generate SQL from Natural Language Prompts procedure and set the Data Studio Settings wizard on the Connections page.Select the tables you wish to generate the SQL query from. You can use the columns from the selected table in the text field where you enter the Natural Query.
Note
You can click Tabular View, drag and drop columns from the navigator to the Columns and Filter drop area to select the intended columns to query. - Click Base Query mode of visualization to enter Natural Language.
Enter the following in the Natural Query Text field:
show me the minimum product price with the product
.Click Generate Query.
Selecting Generate Query converts the Natural language to the equivalent SQL query and displays results under the Query Results tab.
You can alternatively view the query result in tabular view, pivot, and chart view. You can drag and drop rows, columns, and filters from the Tables Browser to the drop area.
Note
From the Chart view you can view the result in horizontal and vertical sheet.
Parent topic: Run Natural Language Query in the Data Analysis Tool