Natural Language to SQL is a powerful AI capability that lets users simply talk to their data—helping developers build applications and business users uncover insights, generate forecasts, and make better decisions. Today’s foundation models are remarkably good at translating natural language into SQL—when they have the right context.
And that’s the catch. Real-world enterprise schemas are rarely designed for a human, let alone for an LLM, to understand. They’re large, complex, full of cryptic names and internal conventions, and often don’t contain enough context to capture what the data actually means. Even the best models are left guessing, and only application experts with knowledge of the schema can credibly compose correct SQL.
That’s why today’s schema-dependent NL2SQL solutions still struggle to deliver consistently high accuracy in the real world. And when the answers drive important business decisions, “sometimes right” simply isn’t good enough to bet your business on.In addition to insufficient schema context there are several other issues with existing NL2SQL solutions:
- Improper handling of language ambiguity – human language is chaotic!
- Lack of intricate knowledge of end-user terminology or jargon, application metrics,and business rules – most models don’t know anything about them.
- Lack of use of human feedback to improve results – NL2SQL systems need to learn from users: what they meant, what went wrong, and what a better answer looks like.
Even a seemingly simple question for an ecommerce application such as “What are the top selling L2 offerables in California?” can expose each of these limitations when run on standard NL2SQL systems.
- Ambiguity: There are many ways to define “top” (how many?) and “selling” (units, bookings, profits, revenue?), many different possible time periods to consider (year-to-date, last quarter, last year?)
- Jargon: “L2 offerable” is an application-specific term that is not common language
- Metrics: Metrics such as profit or revenue, etc. may be defined only in application documentation and not properly defined within the schema
- Rules: E.g., to recognize a product offering as sold, the business may require that the product has not been returned and that the refund window has elapsed but this knowledge may also not be present in the schema.
- Feedback: A one-shot, poor response to this question offers no opportunity to the system to learn from its mistake and not repeat it in the future.
Introducing Oracle’s Deep NL2SQL
Unlike other conventional NL2SQL solutions, Oracle’s Deep NL2SQL agent provides a reliable NL2SQL solution for real enterprise applications, featuring an integrated knowledge-engineering workbench and a feedback driven workflow to address these limitations.
The highlights of this solution include:
- A Business Knowledge Graph built using the knowledge-engineering workbench that extends the schema with additional context required for accurate SQL generation
- A feedback driven workflow that helps clarify language ambiguity and allows iterative knowledge refinement for the agent to improve its accuracy with time
- A built-in regression test featuring vetted natural language to SQL translations that ensures that as knowledge is modified, the system’s accuracy does not deteriorate.
This blog provides further details on Oracle’s Deep NL2SQL agent and describes how you too can now achieve close to 100% accuracy when chatting with your data, after performing the necessary upfront work to set up a knowledge base and a set of representative “gold” SQL statements.
How Does Deep NL2SQL Work?
Deep NL2SQL starts with a simple premise: trustworthy answers require more than syntactically correct SQL. Before generating a query, it works to understand what the user actually means by the question, clarifying ambiguous terms, locating the right business definitions and data relationships, and drawing on prior validated knowledge. As such, the first step with Deep NL2SQL is to build a Business Knowledge Graph:
Business Knowledge Graph
A Business Knowledge Graph organizes enterprise knowledge into “topics” which correspond to information needed to answer expected questions, or categories of questions. For example, for a typical data-warehousing workload, topics in the business knowledge graph could include information about product sales, customer orders, product reviews, and inventory. A question like “What are my total sales from last quarter” would map to the product sales topic, while a question like “What are the top 5 worst reviewed products in 2025” (2026?) would route to the product reviews topic.
The topics in the business knowledge graph may have a hierarchical organization, with a root knowledge topic containing shared enterprise knowledge across many domain-level child topics, and each child topic could further have children representing drill-down topics. Child topics inherit knowledge from their parent topics.

Each knowledge topic contains the information needed to interpret and answer questions within its scope. The contents may include:
- Relevant database schemas, tables, views, columns, and relationships
- Annotations/Comments describing tables, columns, values, and expected usage
- Business glossary terms and metric definitions
- Sample natural-language questions with or without corresponding SQL statements
- Documents containing institutional or application-specific knowledge
For example, a Product Sales knowledge topic may contain:
- Product and Order tables
- Business definitions for concepts like “strategy” and metrics like “profit”
- Instructions to exclude returned products when calculating revenue
- Samples questions applicable for this topic, like “What are the most profitable products”

A business knowledge graph can drastically reduce the amount of irrelevant information presented to the SQL-generation model. Instead of exposing the agent to an entire enterprise schema, the system uses sophisticated database-native search technologies including vectors, text and graph, to identify the topics most likely to contain the data and knowledge specifically required to answer the question – nothing more and nothing less.
Evaluation of Business Knowledge Graph
Once a business knowledge graph is created, it’s NOT expected to be static over time – database tables may change, business definitions may get altered, new topics may get added over time as the agent gets tasked to answer more sophisticated questions. As such, it’s important to establish a workflow that can be used to continuously evaluate the business knowledge graph for accuracy as changes are made.
NL2SQL has a built-in regression workflow just for this purpose – let’s walk through it:
- First, a set of natural language questions, and their associated validated SQL, can be registered as part of Deep NL2SQL’s regression test-suite. We call this the “gold” set. These questions will always be asked during a regression testing run.
- Whenever changes are made to a business knowledge graph, those changes are captured in an unpublished state until those changes are deemed safe to be included into the official, published business knowledge graph that all users see.
- An evaluation workflow can be triggered to run Deep NL2SQL with the gold set using the unpublished business knowledge graph to generate answers.
- If the answers match the expected set, then the changes may be considered safe and the unpublished graph can now be switched into a published state so that all users can see the reflected changes.

The workbench instills best practice to verify that even the slightest changes to the business knowledge graph won’t impact expected behavior. Users of Deep NL2SQL expect 100% trust in the system, and so it’s imperative that the system encourages consistency and determinism in its responses.
Feedback-Driven NL2SQL and Human-in-the-loop
Once the business knowledge graph is created and tested and fully vetted, Deep NL2SQL is ready to be used to answer questions. Even at this stage, however, trust can further be incorporated. Absolutely core to Deep NL2SQL is the ability to solicit feedback from users via human-in-the-loop during every stage of the agent’s conversation with the user to ensure accuracy and trust in the answers. Let’s walk through this:
When a question is asked, the agent first attempts to fully understand the question by gathering knowledge and resolving ambiguity. It does so by first mapping the question to one or more topics in the business knowledge graph. The agent then assesses whether the knowledge contained in those topics fully clarifies the intent of the question. In the event that the agent is dissatisfied, it doesn’t hesitate to ask the business user a clarifying question:

Once the question is understood using a combination of knowledge in the business knowledge graph and human-in-the-loop, it’s time to start generating SQL. The Deep NL2SQL agent is a sophisticated reasoning-based agent that performs question decomposition, query planning, exploratory data analysis, SQL generation and execution, reflection and verification. Throughout every step, Deep NL2SQL may incorporate human-in-the-loop to resolve any concerns it has when answering the question. For example, if the agent is trying to decide on which status should define a “placed order”, if there is insufficient context in the business knowledge graph to answer the question, it will ask the user to provide clarification.

Deep NL2SQL will self-review the final SQL it produced, reflect upon its assumptions and knowledge incorporated from the business knowledge graph, and then submit a final answer back to the user. The SQL it produces is accompanied by all of the thoughts and reasoning that went in to generate the answer, giving the user ample information to fully understand the answer. Even at this stage, trust is factored in. The user may up/down vote the result, which serves as additional feedback for the system to process in the backend.
Incorporating Feedback to Make the System Better
All feedback accumulated during the agent conversation is recorded and logged for subsequent introspection by the agent designer. Ideally the feedback gets added back into the business knowledge graph so that the agent can avoid asking clarifying questions in the future – knowledge gained is knowledge learned. Adding the knowledge back into the business knowledge graph also makes it available for other users to benefit. And with Deep NL2SQL’s evaluation workbench, the changes can be safely added before exposing to users
Summary
Unlike conventional NL2SQL solutions, Deep NL2SQL is designed with trust at its core. It organizes enterprise knowledge into queryable semantic regions through a business knowledge graph, incorporates human-in-the-loop feedback for trusted accuracy, and provides workbenches to create, validate, and maintain both the knowledge graph and its evaluation workflows. Feedback can be safely incorporated as governed, reusable knowledge, enabling the system to improve while preserving consistency, transparency, and confidence in its answers. With Deep NL2SQL, you can talk to your data confidently, and get back trusted answers.

