Database query specification determination method, system and device, medium and program product
By using a pre-defined large model to perform standardization checks and rewrite database query statements, query failures caused by differences in user input habits are resolved, thereby improving query reliability and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- THE CHINESE UNIV OF HONG KONG (SHENZHEN)
- Filing Date
- 2025-12-08
- Publication Date
- 2026-04-24
AI Technical Summary
Existing technologies lack the ability to standardize and intelligently modify instructions, leading to query failures due to differences in user input habits and impacting user experience.
The system performs standardization checks on user-input database query statements using a pre-set large model, generates target query terms or rewrites the statements to conform to the standards, performs structural and grammatical checks using a pre-set system and user-suggested terms, and generates target query terms based on the rewritten information.
It improves query reliability and user experience, automatically corrects non-standard statements, enables fast queries, and solves the problem of query failures caused by different user input habits.
Smart Images

Figure CN121919233A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing, and in particular to a method, system, device, medium, and program product for determining database query specifications. Background Technology
[0002] Under the current technical architecture, the core of the data service system is a high-efficiency information retrieval engine. Its basic workflow is as follows: the system receives the query command input by the user (usually keywords, phrases, or short questions), then performs pattern matching in a preset database or knowledge base, and finally returns the relevant matching information to the user.
[0003] However, in real-world applications, users' behaviors and input habits vary greatly, resulting in the current system lacking the ability to check the standardization of instructions and lacking the ability to intelligently modify instructions. This leads to query failures and directly affects the user experience. Summary of the Invention
[0004] The technical problem to be solved by this disclosure is to overcome the shortcomings of the prior art, which lacks the ability to check the standardization of instructions and does not have the ability to intelligently modify instructions, and to provide a method, system, device, medium and program product for determining database query standards.
[0005] This disclosure solves the above-mentioned technical problems through the following technical solution:
[0006] According to a first aspect of this disclosure, a method for determining database query specifications is provided, the method being implemented based on a preset large model, the method comprising:
[0007] Get the database query statement entered by the user;
[0008] The database query statements are checked for compliance with regulations.
[0009] In response to the database query statement conforming to preset standard conditions, several target query terms matching the user query command are generated based on the preset large model, so as to obtain target information based on the target query terms;
[0010] In response to the database query statement not conforming to the preset standard conditions, the database query statement is rewritten based on the preset standard conditions, and several target query terms matching the rewritten user query instruction are generated based on the preset big model, so as to obtain target information based on the target query terms.
[0011] Optionally, the step of checking the standardization of the database query statement includes:
[0012] The database query statement is checked using the preset large model based on the first preset system prompt words and the preset user prompt words, and the check results are obtained; the first preset system prompt words are used to check the structural regularity of the database query statement; the preset user prompt words are used to check the syntactic regularity of the database query statement.
[0013] In response to the inspection result meeting the first preset condition, the system generates several target query terms that match the user's query instruction based on the preset large model, so as to obtain target information based on the target query terms;
[0014] In response to the fact that the inspection result does not meet the first preset condition, the database query statement is rewritten based on the preset standard condition, and several target query terms matching the rewritten database query statement are generated based on the preset large model, so as to obtain target information based on the target query terms;
[0015] The first preset condition is associated with the preset specification condition.
[0016] Optionally, the step of rewriting the database query statement based on the preset standard conditions and generating several target query terms that match the rewritten user query instruction based on the preset large model includes:
[0017] Based on the inspection results and the first preset conditions, rewrite information is generated;
[0018] The database query statement is rewritten based on the rewritten information.
[0019] Optionally, before the step of checking the normality of the database query statement, the determination method further includes:
[0020] The preset large model is trained based on the preset standard conditions; wherein, the first preset system prompt words include at least one of the following: field basic standard, index standard, field type standard, reserved word standard, and performance key indicator standard.
[0021] Optionally, after the step of responding to the check result not meeting the first preset condition, the determining method further includes:
[0022] A preset user prompt is generated based on the rewritten information.
[0023] Optionally, after the step of obtaining target information based on the target query term, the determination method further includes:
[0024] Obtain several different query terms corresponding to the database query statement, the target information corresponding to the different query terms, the rewritten information, and the preset user prompt;
[0025] A target inspection report is generated based on several different query terms, the target information corresponding to the different query terms, the rewritten information, and the preset user prompts;
[0026] The target inspection report is summarized and output in a preset manner.
[0027] According to a second aspect of this disclosure, a system for determining database query specifications is provided, the system comprising:
[0028] The user statement acquisition module is used to acquire the database query statement input by the user.
[0029] The statement standardization check module is used to check the standardization of the database query statements;
[0030] The processing module is used to respond to the fact that the database query statement conforms to the preset standard conditions, generate a number of target query terms that match the user query command based on the preset large model, and obtain target information based on the target query terms;
[0031] The processing module is also configured to respond to the fact that the standardization of the database query statement does not conform to the preset standard conditions, rewrite the database query statement based on the preset standard conditions, and generate several target query terms that match the rewritten user query command based on the preset big model, so as to obtain target information based on the target query terms.
[0032] Optionally, the statement standardization checking module is also used for:
[0033] The database query statement is checked using the preset large model based on the first preset system prompt words and the preset user prompt words, and the check results are obtained; the first preset system prompt words are used to check the structural regularity of the database query statement; the preset user prompt words are used to check the syntactic regularity of the database query statement.
[0034] In response to the inspection result meeting the first preset condition, the system generates several target query terms that match the user's query instruction based on the preset large model, so as to obtain target information based on the target query terms;
[0035] In response to the fact that the inspection result does not meet the first preset condition, the database query statement is rewritten based on the preset standard condition, and several target query terms matching the rewritten database query statement are generated based on the preset large model, so as to obtain target information based on the target query terms;
[0036] The first preset condition is associated with the preset specification condition.
[0037] Optionally, the processing module is further configured to:
[0038] Based on the inspection results and the first preset conditions, rewrite information is generated;
[0039] The database query statement is rewritten based on the rewritten information.
[0040] Optionally, the determining system further includes: a model adjustment module, which is used to train the preset large model based on the preset standard conditions before checking the standardization of the database query statement; wherein, the first preset system prompt words include at least one of field basic standards, index standards, field type standards, reserved word standards, and performance key indicator standards.
[0041] Optionally, the determining system further includes a user prompt module, which is used to generate a preset user prompt based on the rewritten information after the check result does not meet the first preset condition.
[0042] Optionally, the determining system further includes a statement rewriting module, which is used to obtain, after obtaining the target information based on the target query term, several different query terms corresponding to the database query statement, the target information corresponding to the different query terms, the rewritten information, and the preset user prompt;
[0043] A target inspection report is generated based on several different query terms, the target information corresponding to the different query terms, the rewritten information, and the preset user prompts;
[0044] The target inspection report is summarized and output in a preset manner.
[0045] According to a third aspect of this disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and for running on the processor, wherein the processor executes the computer program to implement the method for determining the database query specification as described in the first aspect of this disclosure.
[0046] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method for determining the database query specification as described in the first aspect of this disclosure.
[0047] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method for determining the database query specification as described in the first aspect of this disclosure.
[0048] Based on common knowledge in the field, the above-mentioned preferred conditions can be combined arbitrarily to obtain various preferred embodiments of this disclosure.
[0049] The positive and progressive effects of this disclosure are as follows:
[0050] The database query specification determination method provided in this disclosure can check whether the database query statement entered by the user conforms to the specification, and can automatically correct non-standard statements into standard statements. Based on this, it can identify the query terms of the corresponding statement to achieve fast data query. It fundamentally solves the problem of query failure caused by different users' different input habits, greatly improves the reliability of the query and enhances the user experience. Attached Figure Description
[0051] Figure 1 This is a flowchart illustrating a method for determining database query specifications provided in Embodiment 1 of this disclosure;
[0052] Figure 2 This is a schematic diagram of the process after obtaining the target information provided in Embodiment 1 of this disclosure;
[0053] Figure 3 This is a schematic diagram of the structure of the trained agent provided in Embodiment 1 of this disclosure;
[0054] Figure 4 This is a schematic diagram of the structure of a database query specification determination system provided in Embodiment 2 of this disclosure;
[0055] Figure 5 This is a schematic diagram of the structure of the electronic device provided in Embodiment 3 of this disclosure. Detailed Implementation
[0056] The present disclosure is further illustrated below by way of embodiments, but the present disclosure is not limited to the scope of the embodiments described herein.
[0057] The prefixes such as "first" and "second" used in this disclosure are merely for distinguishing different descriptive objects and do not limit the position, order, priority, quantity, or content of the described objects. The use of ordinal numbers and other prefixes used to distinguish descriptive objects in this disclosure does not constitute a limitation on the described objects. The description of the described objects is given in the claims or the context of the embodiments, and should not be construed as an unnecessary limitation. Furthermore, in the description of this embodiment, unless otherwise stated, "multiple" means two or more.
[0058] Example 1
[0059] like Figure 1 As shown in this embodiment, a method for determining database query specifications is provided. This method is based on a preset large model and includes the following steps:
[0060] S11: Obtain the database query statement input by the user;
[0061] S12: Check the standardization of database query statements;
[0062] S13: In response to the database query statement conforming to the preset standard conditions, generate several target query terms that match the user query command based on the preset large model, and obtain the target information based on the target query terms; In response to the database query statement not conforming to the preset standard conditions, rewrite the database query statement based on the preset standard conditions, and generate several target query terms that match the rewritten user query command based on the preset large model, and obtain the target information based on the target query terms.
[0063] The steps for checking the standardization of database query statements include:
[0064] A pre-set large model is used to check database query statements based on a first pre-set system prompt and a pre-set user prompt, and the check results are obtained. The first pre-set system prompt is used to check the structural regularity of the database query statements; the pre-set user prompt is used to check the syntactic regularity of the database query statements.
[0065] In response to the inspection result meeting the first preset condition, several target query terms matching the user's query command are generated based on the preset large model, so as to obtain the target information based on the target query terms;
[0066] In response to the fact that the inspection result does not meet the first preset condition, the database query statement is rewritten based on the preset standard conditions, and several target query terms that match the rewritten database query statement are generated based on the preset large model, so as to obtain the target information based on the target query terms.
[0067] The first preset condition is related to the preset standard condition.
[0068] In one example, the first preset system prompt is a system prompt, such as: Inputting the preset large model: You are a database administrator who is good at checking whether SQL statements (a type of database query statement) conform to design specifications.
[0069] In one example, the default user prompt is a user prompt phrase, such as: Check if {SQL} conforms to the specifications in the context, and the check items include:
[0070] 1. Check if the database type is {database_type}
[0071] Furthermore, the database engine is {database_engine} and has certain limitations.
[0072] 2. Does it comply with the database design specifications of the R&D center?
[0073] 3. Other general database design standards
[0074] 4. Check whether the table fields use the database keyword of type {database_type}.
[0075] 5. Check if the index conforms to the specifications.
[0076] 6. Ensure that the number of fields in each table does not exceed 50.
[0077] 7. Calculate the byte length of each row in the table; it should not be too long. Optimization suggestions are required.
[0078] 8. Check if the primary key definition is reasonable.
[0079] It is important to note that the project prefix is {project_pre}, the database version number is {database_version}, and the database engine is {database_engine}. SQL rewriting suggestions should be provided.
[0080] By using the first preset system prompt and the preset user prompt, the system determines whether the database query statement entered by the user is compliant, thereby quickly checking the database query statement and improving the database query efficiency.
[0081] In this embodiment, the steps of rewriting the database query statement based on preset standard conditions and generating several target query terms that match the rewritten user query command based on a preset large model include:
[0082] Rewritten information is generated based on the inspection results and the first preset conditions;
[0083] The database query statement is rewritten based on the rewritten information.
[0084] By generating rewritten information after verifying that the user's input does not conform to the specifications, and then making modifications based on the rewritten information, the accuracy of database queries can be improved.
[0085] In this embodiment, before the step of checking the standardization of the database query statement, the determination method further includes:
[0086] The preset large model is trained based on preset standard conditions; wherein, the first preset system prompt words include at least one of the following: basic field specifications, index specifications, field type specifications, reserved word specifications, and key performance indicator specifications.
[0087] In one example, the first preset system prompt word could be:
[0088] Database design specifications for R&D center;
[0089] PolarDB-x Knowledge Base (Alibaba Cloud's self-developed cloud-native distributed database) (selects relevant HTML (Hypertext Markup Language) knowledge documents from the Alibaba Cloud website, converts them to PDF (a file format) using the wkhtmltopdf tool (an open-source command-line tool), and finally uses a large model and mineru (an intelligent data extraction tool) to process the table content into a form that the large model can easily understand before storing it in the knowledge base).
[0090] Reserved words in MySQL 5.7 (MySQL 5.7 is a key version of the MySQL database series);
[0091] MySQL8 (a reserved word in the current major version of the MySQL database management system (RDBMS));
[0092] Common data types in MySQL (a type of database) and their storage size in bytes.
[0093] By pre-entering database design specifications, a standard is provided for checking user input commands. This standard defines the specific content of the database design specifications and provides a standard for checking database query statements.
[0094] In this embodiment, after the step of responding to the check result not meeting the first preset condition, the determination method further includes: generating a preset user prompt based on the rewritten information.
[0095] By generating user prompts when database query statements do not conform to the specifications, the user experience can be improved.
[0096] like Figure 2As shown, after obtaining target information based on the target query terms, the determination method further includes:
[0097] S21: Obtain several different query terms corresponding to the database query statement, target information corresponding to different query terms, rewrite information, and preset user prompts;
[0098] S22: Generate a target inspection report based on several different query terms, target information corresponding to different query terms, rewritten information, and preset user prompts;
[0099] S23: Summarize and output the target inspection report in a preset manner.
[0100] In one example, the preset methods include, but are not limited to, WORD (word processing software), PDF (portable document format software), PPT (presentation document software), and EXCEL (spreadsheet software). By obtaining several pieces of information corresponding to the data query statement, these pieces of information are compiled into an inspection report and output, thereby improving the user experience.
[0101] In one execution method, for example: the database type is MySQL, the database version number is 8.0.30, the database engine is InnoDB, and the project prefix is "rdc_". The user-inputted table creation statement is as follows:
[0102] CREATE TABLE user (
[0103] id BIGINT,
[0104] name VARCHAR(255),
[0105] desc VARCHAR(1024),
[0106] status INT,
[0107] create_time DATETIME,
[0108] update_time DATETIME,
[0109] remark TEXT,
[0110] col1 VARCHAR(255),
[0111] col2 VARCHAR(255),
[0112] col3 VARCHAR(255),
[0113] col4 VARCHAR(255),
[0114] col5 VARCHAR(255),
[0115] col6 VARCHAR(255),
[0116] col7 VARCHAR(255),
[0117] col8 VARCHAR(255),
[0118] col9 VARCHAR(255),
[0119] col10 VARCHAR(255),
[0120] col11 VARCHAR(255),
[0121] col12 VARCHAR(255),
[0122] col13 VARCHAR(255),
[0123] col14 VARCHAR(255),
[0124] col15 VARCHAR(255),
[0125] col16 VARCHAR(255),
[0126] col17 VARCHAR(255),
[0127] col18 VARCHAR(255),
[0128] col19 VARCHAR(255),
[0129] col20 VARCHAR(255),
[0130] col21 VARCHAR(255),
[0131] col22 VARCHAR(255),
[0132] INDEX idx_status(status)
[0133] ENGINE=InnoDB;
[0134] Based on a pre-defined large model, and in conjunction with the first pre-defined system prompt and the pre-defined user prompt, the standardization of the above SQL statement is checked. The specific judgment process is as follows:
[0135] Database type and engine check: Confirm that ENGINE=InnoDB is consistent with the configured MySQL / InnoDB environment.
[0136] Database design specification check for R&D center: Table names must begin with the project prefix "rdc_", but the current table name is user, so it is judged to be non-compliant.
[0137] General database design standard check: It was found that the table creation statement did not define a primary key field and the total number of fields was too large, prompting the user to evaluate whether the fields are redundant.
[0138] Reserved word check: The field name desc conflicts with the MySQL reserved word "DESC" and is judged as non-standard naming.
[0139] Index specification check: The index name idx_status does not meet the internal requirements (it must be named with the table name prefix), and it is suggested that it should be changed to a naming method that uses the table name prefix.
[0140] Single-row storage length check: The system automatically calculates the row length based on the data type and finds large fields such as VARCHAR(1024) and TEXT, which may cause the row record to be too large.
[0141] Primary key validity check: It is recommended to set the id field as an auto-incrementing primary key.
[0142] Based on the above inspection results, the system generates the following rewrite suggestions: (1) Change the table name to rdc_user; (2) Change the desc field to description; (3) Add a primary key constraint to the id field and set it to auto-increment; (4) Change the index name to idx_rdc_user_status; (5) Provide table partitioning or optimization suggestions for large fields such as remark.
[0143] The automatically generated normalized SQL is as follows:
[0144] CREATE TABLE rdc_user (
[0145] id BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Primary Key ID',
[0146] name VARCHAR(255) NOT NULL COMMENT 'username',
[0147] description VARCHAR(512) NULL COMMENT 'Description information',
[0148] status INT NOT NULL DEFAULT 0 COMMENT 'Status',
[0149] create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
[0150] update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Update time',
[0151] remark TEXT NULL COMMENT 'Remarks',
[0152] col1 VARCHAR(255),
[0153] col2 VARCHAR(255),
[0154] col3 VARCHAR(255),
[0155] col4 VARCHAR(255),
[0156] col5 VARCHAR(255),
[0157] col6 VARCHAR(255),
[0158] col7 VARCHAR(255),
[0159] col8 VARCHAR(255),
[0160] col9 VARCHAR(255),
[0161] col10 VARCHAR(255),
[0162] col11 VARCHAR(255),
[0163] col12 VARCHAR(255),
[0164] col13 VARCHAR(255),
[0165] col14 VARCHAR(255),
[0166] col15 VARCHAR(255),
[0167] col16 VARCHAR(255),
[0168] col17 VARCHAR(255),
[0169] col18 VARCHAR(255),
[0170] col19 VARCHAR(255),
[0171] col20 VARCHAR(255),
[0172] col21 VARCHAR(255),
[0173] col22 VARCHAR(255),
[0174] PRIMARY KEY (id),
[0175] INDEX idx_rdc_user_status (status)
[0176] ) ENGINE=InnoDB COMMENT='Project rdc User Table';
[0177] In addition, the following user prompts will be automatically generated to provide feedback on the inspection results:
[0178] "The following issues were found: 1) Table names did not use the project prefix; 2) The field 'desc' is a reserved word in MySQL; 3) No primary key was defined; 4) Single-row storage length was too large; 5) Index naming was not standardized. Suggested modified SQL has been generated for your reference."
[0179] The database query specification determination method provided in this disclosure can check whether the database query statement entered by the user conforms to the specification, and can automatically correct non-standard statements into standard statements. Based on this, it can identify the query terms of the corresponding statement to achieve fast data query. It fundamentally solves the problem of query failure caused by different users' different input habits, greatly improves the reliability of the query and enhances the user experience.
[0180] The following is combined with Figure 3 The specific implementation principle of the method for determining the database query specification in this disclosure is explained in detail below:
[0181] This disclosure utilizes the workflow orchestration capabilities of Dify (an open-source generative AI application development platform that supports the rapid building and deployment of applications based on large language models through a visual interface) to generate intelligent agent applications. The Dify workflow design concept is as follows:
[0182] First, leveraging the reasoning capabilities of the deepseek-R1 large model (an open-source reasoning-based large language model focused on enhancing logical reasoning abilities and suitable for complex tasks such as mathematical calculations and code generation), a list of query terms for querying the knowledge base is generated based on the user's input SQL.
[0183] The database design specifications of the R&D center and the specific specifications and limitations (such as reserved words) of databases such as PolarDB-x and MySQL will be entered into the knowledge base for future use.
[0184] Use the query term list to retrieve all key knowledge points from the knowledge base and aggregate them into contextual information;
[0185] Finally, using the deepseek R1 large model combined with knowledge base context information, a production inspection report is generated for R&D reference.
[0186] Specifically, the actual configuration method and data processing flow of the Dify workflow include: configuring workflow nodes and required fields, inputting required fields into the model, performing pre-training checks, parameter extractor processing, iterator processing, variable aggregator processing, integration processing, and output.
[0187] The configuration of workflow nodes and required fields includes: creating a "Database Query Specification Check Process" in the Dify workflow editing interface and setting the required parameters for the entry node, including: sql_input (required): the database query statement entered by the user;
[0188] database_type (required): e.g., MySQL, PolarDB-X, etc.;
[0189] database_engine (required): such as InnoDB, X-Engine, etc.;
[0190] project_pre (optional): Table name prefix specification;
[0191] database_version (optional): e.g., 8.0.30;
[0192] Dify forces users to fill in sql_input, database_type, and database_engine when making calls to ensure the integrity of information when making judgments on large models.
[0193] The required fields to be entered into the model include:
[0194] Input the above required parameters, along with the preset system prompts and preset user prompts, into the preset large language model. The preset large language model performs two types of tasks: first, it performs structural compliance checks based on the system prompts; second, it performs grammatical compliance checks based on the user prompts. The output of the preset large language model includes: whether it conforms to the specifications (boolean); inspection report items (such as reserved word issues, index issues, primary key issues, etc.); and a list of suggested query terms (query_terms). For example, it can parse the following from SQL: ["primary key", "mysql keyword", "engineinnodb"]. The above output results are then processed in subsequent nodes.
[0195] The purpose of the parameter extractor is to automatically extract structured variables from the natural language output of the pre-defined large language model for use in subsequent steps. Examples include: `is_valid`: whether the SQL is valid; `rewrite_needed`: whether it needs to be rewritten; `rewrite_suggestions`: a list of modification suggestions generated by the model; and `query_terms`: a list of query terms automatically extracted and normalized from the SQL.
[0196] For example, the default output of a large language model is:
[0197] "This SQL statement has three problems: 1) the field 'desc' is a keyword; 2) a primary key is missing; 3) the table name is not prefixed. It is recommended to change 'desc' to 'description', add the primary key 'id', and rename the table to 'rdc_user'."
[0198] The parameter extractor converts it into standardized JSON: {"is_valid": false,"rewrite_needed":true,"rewrite_suggestions": {"rename_table": "rdc_user","rename_field_desc":"description","add_primary_key": true},"query_terms": ["mysql keywords", "primary key", "field naming rule"]}, thus ensuring that subsequent processes do not rely on natural language, but on stable structured variables.
[0199] The purpose of iterator processing is to query the knowledge base one by one. For example, if the extracted query terms are "primarykey rule", "mysql reserved words", and "table naming rule", the iterator will call the "knowledge base retrieval node (RAG node)" once for each query_term to retrieve pre-entered specification documents, including: R&D center database design specifications, PolarDB-X official restriction documents, MySQL 5.7 / 8.0 reserved word documents, common data types and byte count tables. Each retrieval will return a "key specification knowledge fragment".
[0200] The purpose of variable aggregator processing is to integrate all search results. Each iterator retrieves a knowledge fragment (such as "primary keys must be unique and cannot be null" or "desc is a reserved word"). The aggregator integrates all search results into a unified context_all, for example: {"primary_key_rule": "...","reserved_word_rule": "...","table_prefix_rule": "...","index_design_rule": "..."}. The context aggregated by the variable aggregator will serve as the input for the next call to the pre-defined large language model, enabling the model to generate the final report based on complete knowledge.
[0201] The goal of the integration process is to generate a complete specification check report, including the original SQL, check results and rewrite suggestions, and aggregated knowledge base content (context_all).
[0202] Based on this, the pre-defined large language model generates the final "normative check report," which includes:
[0203] The original SQL, the results of each check, detailed error descriptions, rewrite suggestions, automatically generated normalized SQL statements, and natural language summaries for the user.
[0204] Example output (simplified version):
[0205] "The SQL you entered has three non-compliant issues: 1) desc is a reserved word; 2) a primary key is missing; 3) the table name is not prefixed. The rewritten SQL has been automatically generated for you according to the specifications."
[0206] The final output summarizes the original statements, inspection results, rewritten information, information corresponding to different query terms, automatically generated SQL rewrites, and user prompts into a final inspection report. The exported format is Word (referring to the file format generated by Microsoft Word (.doc or .docx)), PDF (a fixed-format electronic document format developed by Adobe (.pdf)), or JSON (a lightweight data exchange format (.json)), using a human-readable and easy-to-write text format. This disclosure utilizes large models and RAG (Retrieval Enhancement Generation) technology to automatically check whether database table creation statements conform to the R&D center's specifications and specific databases. Furthermore, it can consider the limitations of different databases, such as PolarDB-X and MySQL, and list corresponding statement optimization suggestions, improving the efficiency and quality of R&D review of database table creation statements.
[0207] Example 2
[0208] like Figure 4 As shown, this embodiment provides a system for determining database query specifications. The system includes:
[0209] User statement acquisition module 100 is used to acquire the database query statement input by the user;
[0210] The statement standardization check module 200 is used to check the standardization of database query statements;
[0211] The processing module 300 is used to respond to the database query statement's conformity to preset standard conditions, generate several target query terms that match the user's query command based on a preset large model, and obtain target information based on the target query terms;
[0212] The processing module 300 is also used to respond to the fact that the standardization of the database query statement does not meet the preset standard conditions, rewrite the database query statement based on the preset standard conditions, and generate several target query terms that match the rewritten user query command based on the preset large model, so as to obtain the target information based on the target query terms.
[0213] The statement standardization checking module 200 in this embodiment is also used for:
[0214] A pre-set large model is used to check database query statements based on a first pre-set system prompt and a pre-set user prompt, and the check results are obtained. The first pre-set system prompt is used to check the structural regularity of the database query statements; the pre-set user prompt is used to check the syntactic regularity of the database query statements.
[0215] In response to the inspection result meeting the first preset condition, several target query terms matching the user's query command are generated based on the preset large model, so as to obtain the target information based on the target query terms;
[0216] In response to the fact that the inspection result does not meet the first preset condition, the database query statement is rewritten based on the preset standard conditions, and several target query terms that match the rewritten database query statement are generated based on the preset large model, so as to obtain the target information based on the target query terms.
[0217] The first preset condition is related to the preset standard condition.
[0218] In this embodiment, the processing module 300 is also used for:
[0219] Rewritten information is generated based on the inspection results and the first preset conditions;
[0220] The database query statement is rewritten based on the rewritten information.
[0221] The determination system in this embodiment further includes a model adjustment module 400, which is used to train a preset large model based on preset standard conditions before checking the standardization of the database query statement; wherein, the first preset system prompt words include at least one of field basic standardization, index standardization, field type standardization, reserved word standardization, and performance key indicator standardization.
[0222] The determination system in this embodiment also includes a user prompt module 500, which is used to generate a preset user prompt based on the rewritten information after the check result does not meet the first preset condition.
[0223] The determination system in this embodiment also includes a statement rewriting module 600. The statement rewriting module 600 is used to obtain several different query terms corresponding to the database query statement, the target information corresponding to the different query terms, the rewriting information, and the preset user prompts after obtaining the target information based on the target query terms.
[0224] A target inspection report is generated based on several different query terms, the target information corresponding to the different query terms, the rewritten information, and the preset user prompts.
[0225] The target inspection report is compiled and output in a preset manner.
[0226] For the system embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this disclosure according to actual needs.
[0227] The database query specification determination system provided in this disclosure can check whether the database query statement entered by the user conforms to the specification, and can automatically correct non-standard statements into standard statements. Based on this, it can identify the query terms of the corresponding statement to achieve fast data query. It fundamentally solves the problem of query failure caused by different users' different input habits, greatly improves the reliability of the query and enhances the user experience.
[0228] Example 3
[0229] like Figure 5 As shown, Figure 5 This is a schematic diagram of the corresponding electronic device provided in Embodiment 3 of this disclosure. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the methods described in the above embodiments. Figure 5 The electronic device 30 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0230] like Figure 5 As shown, the electronic device 30 can be represented in the form of a general computing device, such as a server device. The components of the electronic device 30 may include, but are not limited to: at least one processor 31, at least one memory 32, and a bus 33 connecting different system components (including memory 32 and processor 31).
[0231] Bus 33 includes a data bus, an address bus, and a control bus.
[0232] The memory 32 may include volatile memory, such as random access memory (RAM) 321 and / or cache memory 322, and may further include read-only memory (ROM) 323.
[0233] The memory 32 may also include a program / utility 325 having a set (at least one) of program modules 324, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.
[0234] The processor 31 performs various functional applications and data processing, such as the methods described in the above embodiments of this disclosure, by running computer programs stored in the memory 32.
[0235] Electronic device 30 can also communicate with one or more external devices 34 (e.g., keyboard, pointing device, etc.). This communication can be performed via input / output (I / O) interface 35. Furthermore, the model-generating device 30 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 36. Figure 5 As shown, network adapter 36 communicates with other modules of the model-generated device 30 via bus 33. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the model-generated device 30, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems.
[0236] It should be noted that although several units / modules or sub-units / modules of the electronic device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided and embodied by multiple units / modules.
[0237] Example 4
[0238] This disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for determining database query specifications provided in any of the above embodiments.
[0239] The readable storage medium may be more specifically adopted, including but not limited to: portable disk, hard disk, random access memory, read-only memory, erasable programmable read-only memory, optical storage device, magnetic storage device, or any suitable combination thereof.
[0240] Example 5
[0241] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the method for determining the database query specification as described in any of the preceding embodiments.
[0242] The program code for executing the computer program product of this disclosure can be written in any combination of one or more programming languages, and the program code can be executed entirely on a user device, partially on a user device, as a stand-alone software package, partially on a user device and partially on a remote device, or entirely on a remote device.
[0243] While specific embodiments of this disclosure have been described above, those skilled in the art should understand that these are merely illustrative examples, and the scope of protection of this disclosure is defined by the appended claims. Those skilled in the art can make various changes or modifications to these embodiments without departing from the principles and essence of this disclosure, but all such changes and modifications fall within the scope of protection of this disclosure.
Claims
1. A method for determining database query specifications, characterized in that, The determination method is based on a preset large model, and the determination method includes: Get the database query statement entered by the user; The database query statements are checked for compliance with regulations. In response to the database query statement conforming to preset standard conditions, several target query terms matching the user query command are generated based on the preset large model, so as to obtain target information based on the target query terms; In response to the database query statement not conforming to the preset standard conditions, the database query statement is rewritten based on the preset standard conditions, and several target query terms matching the rewritten user query instruction are generated based on the preset big model, so as to obtain target information based on the target query terms.
2. The method for determining database query specifications according to claim 1, characterized in that, The steps for checking the standardization of the database query statement include: The database query statement is checked using the preset large model based on the first preset system prompt words and the preset user prompt words, and the check results are obtained; the first preset system prompt words are used to check the structural regularity of the database query statement; the preset user prompt words are used to check the syntactic regularity of the database query statement. In response to the inspection result meeting the first preset condition, the system generates several target query terms that match the user's query instruction based on the preset large model, so as to obtain target information based on the target query terms; In response to the fact that the inspection result does not meet the first preset condition, the database query statement is rewritten based on the preset standard condition, and several target query terms matching the rewritten database query statement are generated based on the preset large model, so as to obtain target information based on the target query terms; The first preset condition is associated with the preset specification condition.
3. The method for determining database query specifications according to claim 2, characterized in that, The step of rewriting the database query statement based on the preset standard conditions and generating several target query terms that match the rewritten user query command based on the preset large model includes: Based on the inspection results and the first preset conditions, rewrite information is generated; The database query statement is rewritten based on the rewritten information.
4. The method for determining database query specifications according to claim 3, characterized in that, Before the step of checking the standardization of the database query statement, the determination method further includes: The preset large model is trained based on the preset standard conditions; wherein, the first preset system prompt words include at least one of the following: field basic standard, index standard, field type standard, reserved word standard, and performance key indicator standard.
5. The method for determining database query specifications according to claim 3, characterized in that, After the step of responding to the check result not meeting the first preset condition, the determining method further includes: A preset user prompt is generated based on the rewritten information.
6. The method for determining database query specifications according to claim 5, characterized in that, After the step of obtaining target information based on the target query term, the determination method further includes: Obtain several different query terms corresponding to the database query statement, the target information corresponding to the different query terms, the rewritten information, and the preset user prompt; A target inspection report is generated based on several different query terms, the target information corresponding to the different query terms, the rewritten information, and the preset user prompts; The target inspection report is summarized and output in a preset manner.
7. A system for determining database query specifications, characterized in that, The determining system includes: The user statement acquisition module is used to acquire the database query statement input by the user. The statement standardization check module is used to check the standardization of the database query statements; The processing module is used to respond to the fact that the database query statement conforms to the preset standard conditions, generate a number of target query terms that match the user query command based on the preset large model, and obtain target information based on the target query terms; The processing module is also configured to respond to the fact that the standardization of the database query statement does not conform to the preset standard conditions, rewrite the database query statement based on the preset standard conditions, and generate several target query terms that match the rewritten user query command based on the preset big model, so as to obtain target information based on the target query terms.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and for running on the processor, characterized in that, When the processor executes the computer program, it implements the method for determining the database query specification as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method for determining the database query specification as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for determining the database query specification as described in any one of claims 1 to 6.