The invention provides a
data query method and
system for converting a
natural language into a
database query language, and the method comprises the steps: analyzing the
natural language input of a user through a multi-
modal understanding agent on the basis of constructing a dynamic
knowledge graph based on
metadata, combining a historical session with a business term table, eliminating
ambiguity, and generating a standardized Query, a retrieval routing agent selects a query strategy according to Query complexity, simple query directly matches a cache template, complex query traverses a
knowledge graph, and related tables, fields and service constraints are returned; then, an expert committee agent generates an
SQL (Structured
Query Language) by adopting multi-stage
collaboration, executes plan pre-evaluation, and selects a version with the highest comprehensive
score; the
test agent simulates and executes the
SQL in the isolation environment, and verifies the grammar legality and the field permission; and finally, executing the detected
SQL, and
processing a result. According to the method, the accuracy of converting the
natural language into the SQL (NL2SQL) in a complex
database scene can be effectively improved.