The disclosure provides a structured
query language generation method, which comprises: obtaining original query text input by a user;
rewriting the original query text based on a
large model to obtain rewritten query text; extracting sub-
database schema information related to the rewritten query text from a
database based on the rewritten query text; and generating a target structured
query language statement based on the rewritten query text and the sub-
database schema information. Thus, by
rewriting the original query of the user first, ambiguities in the original expression, such as colloquialism, specialization or context dependence, can be eliminated, making the query more matched with the
database structure; then, based on the rewritten query, sub-
database schema extraction is performed, only retaining table structure information related to the current query, greatly reducing the input size; finally, the
SQL statement is generated based on the simplified and highly
relevant information, which can effectively reduce the model hallucination risk and significantly improve the accuracy and reliability of the generated
SQL.