The invention relates to the field of
database management and
natural language processing, and particularly discloses a
database sub-mode division-based txt-to-
sql generation method, which comprises the following steps of: S1, constructing a
database graph; s2, the weighted
undirected graph G is subjected to sub-mode division based on graph segmentation, a plurality of sub-graphs are obtained, and each sub-graph corresponds to a database sub-mode; s3, generating a sub-mode abstract; s4, a two-stage matching mechanism is adopted, and an optimal sub-mode most relevant to
natural language query input by the user is selected from the sub-mode set; and S5, on the basis of the optimal sub-mode, the corresponding abstract and a user
natural language query construction cue word, inputting the
large model to generate an
SQL query statement. According to the technical scheme provided by the invention, the
static structure and the
dynamic query behavior of the database are fused, the high-correlation sub-
modes are automatically divided, the correlation sub-
modes are accurately positioned through two-stage matching, the input complexity of a
large model is greatly reduced, the accuracy and efficiency of
SQL generation are improved, and the method is adaptive to a large-scale database scene.