Natural Language in Excel Sheet
You can use Natural Language Query to query the Oracle Autonomous Database using the Natural Language menu in the Oracle Autonomous Database for Excel .
Prerequisites
-
Before you use the Natural Language menu in the add-on, you must perform prerequisites to use
DBMS_CLOUD_AI
to configure AI profiles. - Create and Set an AI Profile
After your AI Profile is ready, the Data Studio tool uses these profiles in the Data Studio Settings menu to configure access to a Large Language Model (LLM) and to setup for generating, running, and explaining SQL based on natural language prompts. This also enables chatting with the LLM.
You can run Natural Language Queries on Tables and not Analytic Views.
Generate SQL Queries from Natural Language on Tables
Using natural language to interact with your database data is now achievable with Oracle Autonomous Database add-on for Google Sheets.
This means you can use natural language, for example, plain English, to query the database. You can provide a natural language prompt instead of SQL code to interact with your data. When you select the Generate SQL from natural query icon, the add-on converts natural language to SQL.
- On the Excel Sheet, select the menu Oracle Autonomous Database.
- Select Natural Language. Selecting Natural Language opens a Natural Language wizard.
- On Natural Language wizard, select the Table on which you perform the query from the drop-down and the AI profile you want to use from the drop-down.
- Let’s say you want details of the product with highest sales. Enter the following natural language query in the query display area:
show movie with highest sales
- Select Generate SQL from natural query to produce the equivalent SQL query in the bottom query display area.
You will view the following code in the bottom SQL code area.
SELECT * FROM "MOVIESTREAM"."MOVIESALES_WEEKEND_USA" MS WHERE MS."SALES_AMT" = ( SELECT MAX("SALES_AMT") FROM "MOVIESTREAM"."MOVIESALES_WEEKEND_USA" )
- Selecting the Generate SQL from natural query icon also displays the result of the natural language query in the Google Sheet.
You can click the + sign beside the Select worksheet drop-down to display the results in a new worksheet.
- Click Clear query content to clear the content displayed on the natural language query area and the SQL code query area.
Actions you can perform from the SQL code area:
- Execute SQL: Runs SQL code and displays the query result in Google Sheet.
- Retrieve query from Sheet:
You can retrieve SQL query displayed in the Google Sheet to the SQL code area in the Natural Query.
This feature is to retrieve the latest data from the database for a future date. For example, if you want to receive the latest data from the table the next day, the connection may be inactive, but you can still connect to the instance, retrieve query from Sheet and select Execute SQL to display the latest query results in the Google Sheet.
- SQL Query Explainer: Explains SQL code in Natural language form.
Select this icon to translate SQL queries to natural language that is understood by you. The natural language query is displayed in the natural language query display area of the wizard.
Ask Questions with Chats
Chats option in the Oracle Autonomous Database for Google Sheets refer to an interactive conversation between you and the add-on where the add-on uses natural language to query or interact with the autonomous database.
The data we use in this example is of a company called Oracle MovieStream
to analyze movie sales data.
The Chats displays recommendations for the default table you select.
- Enter the text in the Start typing your question.. text field.
What are the top 5 movies by Weekend Gross?
-
Click Enter.
-
The Chat displays top 5 movies by Weekend Gross.
It also displays equivalent SQL code of the result.
Click SQL to expand the SQL.
Click Copy to clipboard to copy the SQL.
Click Run SQL to run the generated SQL query and display the query result in Google Sheet.
The Chats option remembers the context of previous chat history.
For example, if you enter
now show me top 10
in the text field.It displays the top 10 movies by Weekend Gross. It remembers which metric top 10 to fetch without us having to type the whole thing.
Select New Chat for deleting the present conversation.
Select Home to go back to the main home page.
LLMs are remarkable at inferring intent from the human language and they are getting better all the time; however, they are not perfect! It is very important to verify the results.
Parent topic: Oracle Autonomous Database for Excel