Database-independent method for generating SQL statements

By establishing a database type mapping table and using a syntax tree to replace nodes, the problem of low efficiency in generating database-independent SQL statements in existing technologies is solved, achieving efficient and accurate SQL statement generation and execution.

CN116340337BActive Publication Date: 2026-04-10HANGZHOU NEWGRAND TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-21
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing technologies lack efficient database-independent SQL statement generation solutions, resulting in the need to manually write SQL statements for each new database, which is inefficient and prone to errors.

Method used

By registering standard expressions, a table is established to map SQL expressions to standard expressions for different database types. A syntax tree is constructed, and nodes are replaced on the syntax tree to generate database-independent SQL statements. Combined with syntax validation and execution time prediction rules, the correctness and efficiency of the generated SQL statements are ensured.

Benefits of technology

It enables efficient and accurate generation of database-independent SQL statements, improving generation efficiency, ensuring statement correctness and execution efficiency, and avoiding the inefficiency and errors of handwritten SQL statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116340337B_ABST
    Figure CN116340337B_ABST
Patent Text Reader

Abstract

The present application relates to the field of information technology, in particular to a database-independent SQL statement generation method, comprising the following steps: registering a standard expression, establishing a corresponding relation table; receiving a database operation statement composed of the standard expression; establishing a syntax tree of the database operation statement; replacing the syntax node of the standard expression with the syntax node of the SQL expression of the corresponding database type on the syntax tree; converting the syntax tree into a SQL statement; submitting the SQL statement to the database for execution and obtaining a database response; and feeding back the database response to the user. The beneficial technical effects of the present application include: through the establishment of the corresponding relation table, the expression level is contrasted and converted, through the simple and limited corresponding relation, the generation of complex or nested SQL statements can be supported, and the efficiency of the database-independent SQL statement generation is improved; through the syntax tree as the intermediate body of the conversion, the correctness of the SQL statement generation can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of information technology, in particular to a database-independent method for generating SQL statements. BACKGROUND

[0002] Xin creation, namely information technology application innovation industry, it is the basis of data security and network security, and is an important part of new infrastructure, referred to as "Xin creation". Information technology application innovation development is a national strategy at present, and is also a new motive force for national economic development under the current situation. Developing Xin creation is to solve the problem of essential safety. Change information technology application into an industry that can be controlled, researched, developed and produced. The development of Xin creation industry has become the key to economic digital transformation and the promotion of industrial chain development. From the aspects of technology system introduction, strengthening of industrial foundation and strengthening of guarantee capacity, it promotes the local rooting of Xin creation industry, drives the transformation of traditional IT information industry, and constructs regional industrial agglomeration cluster.

[0003] In Xin creation, business systems are required to support multiple databases, such as Oracle, Mysql, and Sqlserver. Traditional ORM technology can solve some of the different database SQL generation problems. However, some complex SQL can only be handwritten according to different data, and then the type of database is called in the program code. This results in the need to write a SQL statement for some complex queries once for each additional database, which is inefficient and prone to errors. Therefore, it is necessary to study new database-independent SQL statement generation technology.

[0004] The prior art discloses a method for automatically generating SQL statements. First, a data model corresponding to a target data table in a database is determined according to a user inputted preset programming interface instruction. The data model includes specific annotations, which are used to determine the correspondence between the data model and the target data table and the necessary parameters for generating a standard format SQL statement. Then, the specific markers in the data model are used to generate a standard format SQL statement using a preset generation rule by calling a preset programming interface. Each part of the standard format SQL statement has a corresponding relationship with the specific annotations. The technical solution of the present application automatically generates a standard format SQL statement from the specific annotations according to the preset generation rule by calling the preset programming interface. However, the technical solution of the present application generates the SQL statement with the help of specific annotations, and needs to establish all specific annotations in advance and use the preset programming interface instruction, which results in a large amount of work for preparing the preset programming interface instruction and specific annotations, and the efficiency of generating the SQL statement is still very low. SUMMARY

[0005] The technical problem solved by the present application: the current lack of high efficiency of generating database-independent SQL statement scheme. A database-independent SQL statement generation method is proposed, which can quickly realize the generation of database-independent SQL statements.

[0006] To solve the above technical problems, the present application adopts the following technical solutions: a database-independent SQL statement generation method, comprising the following steps:

[0007] Registering a standard expression, establishing a corresponding relationship table of SQL expressions of different database types and the standard expression;

[0008] Receiving a database operation statement composed of a standard expression;

[0009] Establishing a syntax tree of the database operation statement;

[0010] According to the corresponding relationship table, replacing the nodes of the standard expression with the nodes of the SQL expression of the corresponding database type on the syntax tree;

[0011] Converting the syntax tree into a SQL statement;

[0012] Submitting the SQL statement to the database for execution to obtain a database response;

[0013] Feeding back the database response to the user.

[0014] As a preferred, the method of registering a standard expression comprises:

[0015] Listing a plurality of SQL expressions of different database types;

[0016] Dividing SQL expressions with the same function into a group;

[0017] Registering a standard expression for each group of expressions, the standard expression including an operation word and a plurality of parameter placeholders, the operation word of the standard expression being globally unique, and the plurality of parameter placeholders corresponding to all parameters of the SQL expressions in the same group.

[0018] As a preferred, the corresponding relationship table includes a keyword correspondence table and a node correspondence table, and the method of establishing the corresponding relationship table comprises:

[0019] Establishing the syntax tree nodes of each group of SQL expressions and the corresponding standard expressions;

[0020] If the structure of the syntax tree node of the SQL expression is different from the structure of the syntax tree node of the standard expression, associating the syntax tree node structure of the SQL expression with the syntax tree node structure of the corresponding standard expression, and storing it in the node correspondence table;

[0021] If the structure of the syntax tree node of the SQL expression is the same as the structure of the syntax tree node of the standard expression, the keyword of the SQL expression is associated with the keyword of the corresponding standard expression, and the corresponding keyword table is stored.

[0022] As a preferred embodiment, the method of replacing the node of the standard expression with the node of the SQL expression on the syntax tree comprises:

[0023] traversing each node of the syntax tree;

[0024] If the node keyword matches the record in the corresponding keyword table, the node keyword is replaced with the keyword in the record of the corresponding keyword table;

[0025] If the node keyword matches the record in the corresponding node table, the node is replaced with the syntax tree node structure in the record of the corresponding node table.

[0026] As a preferred embodiment, the method further comprises a standard expression auxiliary generation method for converting an existing SQL expression into a database operation statement composed of standard expressions,

[0027] The standard expression auxiliary generation method comprises the following steps:

[0028] establishing a syntax tree of the existing SQL expression;

[0029] According to the corresponding relationship table, the node of the existing SQL expression is replaced with the node of the standard expression on the syntax tree;

[0030] The syntax tree is converted into a database operation statement composed of standard expressions.

[0031] As a preferred embodiment, after receiving the database operation statement composed of standard expressions, a statement verification step is performed, which comprises the following steps:

[0032] The database operation statement is subjected to syntax verification using a pre-established syntax verification rule. If the syntax verification rule is not met, it is determined that the verification is not passed, and an alarm is issued. If the syntax verification rule is met, it is determined that the syntax verification is passed, and an execution verification is performed.

[0033] The execution time of the database operation statement is predicted using a pre-established execution time prediction rule. If the predicted execution time exceeds a preset threshold, it is determined that the execution verification is not passed, and an alarm is issued. Otherwise, if the predicted execution time does not exceed the preset threshold, it is determined that the execution verification is passed.

[0034] As a preferred embodiment, the method of establishing a syntax verification rule comprises:

[0035] Setting a check rule for each keyword, the check rule including an expression check rule and a parameter value check rule, the expression check rule recording an expression that the keyword needs to be combined with, and the parameter value check rule recording a value range of a parameter of the combined expression;

[0036] Comparing each keyword of the database operation statement with a corresponding keyword check rule respectively, if the keyword does not combine with the combined expression recorded by the expression check rule or the parameter of the combined expression exceeds the value range, it is determined that the syntax verification of the database operation statement fails, otherwise, if the keyword combines with the combined expression recorded by the expression check rule and the parameter of the combined expression is in the value range, it is determined that the syntax verification of the database operation statement passes.

[0037] Preferably, the method for establishing the execution time prediction rule comprises:

[0038] Associating a time consumption value with the conditional expression, the inline expression, the outlin expression and the sorting expression respectively, the time consumption value of the conditional expression being a negative value, and the time consumption values of the inline expression, the outlin expression and the sorting expression being positive values;

[0039] Listing the conditional expression, the inline expression, the outlin expression and the sorting expression of the database operation statement;

[0040] Adding the time consumption values corresponding to the conditional expression, the inline expression, the outlin expression and the sorting expression as a predicted value of the execution time consumption of the database operation statement.

[0041] The beneficial technical effects of the present application include: by establishing a corresponding relationship table, expression level comparison and conversion are realized, complex or nested SQL statements can be supported by simple and limited corresponding relationship, and the efficiency of database-independent SQL statement generation is improved; by taking the syntax tree as an intermediate body of conversion, the correctness of SQL statement generation can be ensured, and the efficiency of SQL statement generation can be improved; by means of the keyword corresponding table and the node corresponding table, keyword replacement and syntax node replacement are realized respectively, and efficient and accurate SQL statement generation is realized; by the statement verification step, SQL statements that do not meet the preset verification rule are filtered out, and the execution efficiency of the SQL statement is improved.

[0042] Other features and advantages of the present application will be disclosed in detail in the following specific embodiments and drawings. BRIEF DESCRIPTION OF DRAWINGS

[0043] The present application will be further described below in combination with the drawings:

[0044] Figure 1The SQL statement generation method flowchart for the embodiment of the present application is shown in the figure.

[0045] Figure 2 The standard expression registration method flowchart for the embodiment of the present application is shown in the figure.

[0046] Figure 3 The corresponding relationship table establishment method flowchart for the embodiment of the present application is shown in the figure.

[0047] Figure 4 The node replacement method flowchart for the embodiment of the present application is shown in the figure.

[0048] Figure 5 The standard expression auxiliary generation method flowchart for the embodiment of the present application is shown in the figure.

[0049] Figure 6 The execution time consumption prediction rule establishment method flowchart for the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0050] The technical solutions of the embodiments of the present application are explained and described below in combination with the drawings of the embodiments of the present application, but the following embodiments are only preferred embodiments of the present application, not all. Based on the embodiments in the embodiments, other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the present application.

[0051] In the following description, the appearance of terms such as 'in', 'out', 'up', 'down', 'left', 'right', etc. only for the convenience of describing the embodiments and simplifying the description, not indicating or implying that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, therefore cannot be understood as a limitation of the present application.

[0052] Before introducing the technical solutions of the present embodiment, the application scenario of the present embodiment is introduced.

[0053] In the background of Xinxin, network applications need to support multiple types of databases to improve the deployable range of applications and improve the efficiency of application running. For different types of databases, due to the difference of syntax or keywords of statements, database-independent SQL statement generation technology is needed. The existing technology has an ORM technology, that is, object relational mapping (Object Relational Mapping, ORM for short) is a technology to solve the mismatch between object-oriented and relational databases. The ORM framework is a bridge to connect the database. As long as the mapping relationship between the persistent class and the table is provided, the ORM framework can refer to the information of the mapping file to persist the object to the database. Since ORM uses class mapping with table, it cannot correctly form mapping when performing some user-defined SQL statements that are not commonly used. Therefore, it is still necessary to study the database-independent SQL statement generation technology.

[0054] To this end, the embodiment provides a database-independent SQL statement generation method, please refer to the attached Figure 1 , comprising the following steps:

[0055] Step A01) register standard expressions, and establish a corresponding relationship table of SQL expressions of different database types and standard expressions;

[0056] Step A02) receive a database operation statement composed of standard expressions;

[0057] Step A03) establish a syntax tree of the database operation statement;

[0058] Step A04) replace the nodes of the standard expressions with the nodes of the SQL expressions of the corresponding database type on the syntax tree according to the corresponding relationship table;

[0059] Step A05) convert the syntax tree into a SQL statement;

[0060] Step A06) submit the SQL statement to the database for execution and obtain a database response;

[0061] Step A07) feedback the database response to the user.

[0062] The embodiment realizes the contrast conversion at the expression level, the expression supports nesting, and thus complex or uncommon or custom statements can realize correct conversion. The simple and limited correspondence relation can support complex or nested SQL statement generation, and improves the efficiency of the database-independent SQL statement generation. The embodiment takes the syntax tree as the intermediate body of the conversion, can guarantee the correctness of the SQL statement generation, and can improve the efficiency of the SQL statement generation. With the aid of the keyword correspondence table and the node correspondence table, the keyword replacement and the syntax node replacement are realized, and the efficient and accurate SQL statement generation is realized.

[0063] Please refer to the accompanying drawings Figure 2 The method for registering the standard expression comprises the following steps:

[0064] Step B01) listing the SQL expressions of multiple database types;

[0065] Step B02) dividing the SQL expressions with the same function into a group;

[0066] Step B03) registering a standard expression for each group of expressions, the standard expression comprising an operation word and a plurality of parameter placeholders, the operation word of the standard expression being globally unique, and the plurality of parameter placeholders corresponding to all the parameters of the SQL expressions in the same group.

[0067] The functions of the SQL expressions include query, upgrade, deletion, function, comparison, creation of a new table, modification of a table, deletion of a table, addition of a column, modification of a column, deletion of a column, addition of a primary key, creation of an index, and creation of a view. For the query SQL statement, different database types have little difference, as shown in Table 1.

[0068] Table 1 Query SQL statements of different databases

[0069] Function Standard expression Oracle database SQLserver Query Select(column name) from(table name) where(condition) group by(column name) sort by(column name) SELECT column name FROM table name WHERE condition GROUP BY column name ORDER BY column name SELECT column name FROM table name WHERE condition GROUP BY column name ORDER BY column name

[0070] For the function, the SQL statements of different types of databases have obvious differences. As shown in Table 2, the difference of the SQL statements of the judgment non-empty function in different types of databases.

[0071] Table 2 SQL statements of different databases for the isNull function

[0072] Function Standard expression Oracle database Dream database Mysql SQLserver Function isNull isNull(column name, value) nvl(column name, value) nvl(column name, value) ifnull(column name, value) isNull(column name, value)

[0073] As shown in Table 2, in different types of databases, the functions with the same function have different function keywords although the syntax structures are the same.

[0074] Table 3 SQL statements of different databases for the comparison expression

[0075] Function Standard expression Oracle database Mysql SQLserver Comparison expression Colname!= null Colname is not null Colname is not null and Colname<>"" Colname is not null and Colname<>""

[0076] As shown in Table 3, in different types of databases, the same expression has different keywords and different syntax structures. In Table 3, Colname refers to column name. In the case of both keyword and syntax structure differences, the standard expression needs to be replaced by the node of the corresponding type of database at the node corresponding to the syntax tree.

[0077] In the embodiment, the correspondence table includes a keyword correspondence table and a node correspondence table. Please refer to the attached Figure 3 The method for establishing the correspondence table includes:

[0078] Step C01) Establishing the syntax tree node of each group of SQL expressions and the corresponding standard expression;

[0079] Step C02) If the structure of the syntax tree node of the SQL expression is different from the structure of the syntax tree node of the standard expression, associating the structure of the syntax tree node of the SQL expression with the structure of the syntax tree node of the standard expression and storing it into the node correspondence table;

[0080] Step C03) If the structure of the syntax tree node of the SQL expression is the same as the structure of the syntax tree node of the standard expression, associating the keyword of the SQL expression with the keyword of the standard expression and storing it into the keyword correspondence table.

[0081] If the node structure of the SQL expression in the syntax tree is the same as the node structure of the standard expression in the syntax tree, it means that the SQL expression of the corresponding type of database and the standard expression are only different in keywords. The replacement relationship of the keywords used by the expression can be recorded through the keyword correspondence table. If the node structure of the SQL expression in the syntax tree is not the same as the node structure of the standard expression in the syntax tree, it means that the SQL expression of the corresponding type of database and the standard expression are not only different in keywords but also different in syntax. The replacement relationship of the node structure in the syntax tree can be recorded through the node correspondence table. When converting in the syntax tree, the node structure of the standard expression is replaced by the node structure of the SQL expression of the corresponding type of database. After the replacement, the syntax tree is converted into a SQL statement.

[0082] On the other hand, the embodiment provides a method for replacing the node of the standard expression with the node of the SQL expression on the syntax tree. Please refer to the attached Figure 4 , which includes:

[0083] Step D01) Traversing each node of the syntax tree;

[0084] Step D02) If the node keyword has a corresponding record in the keyword correspondence table, replacing the node keyword with the keyword recorded in the keyword correspondence table;

[0085] Step D03) If the node keyword matches the record in the node correspondence table, replace the node with the syntax tree node structure recorded in the node correspondence table.

[0086] The replacement of the standard expression and the corresponding type database SQL statement in the syntax tree can not only replace the keywords, but also accurately and quickly replace the expressions with different syntax structures. After the replacement, the syntax tree is converted into the SQL statement, and the conversion of the standard expression and the corresponding type database SQL is completed. The generation of the database-independent SQL statement is realized.

[0087] The method for generating the SQL statement provided in the embodiment further includes a standard expression auxiliary generation method. The standard expression auxiliary generation method is used to convert an existing SQL expression into a database operation statement composed of standard expressions. Please refer to the accompanying drawings Figure 5 The standard expression auxiliary generation method includes the following steps:

[0088] Step E01) Establish a syntax tree of the existing SQL expression;

[0089] Step E02) Replace the node of the existing SQL expression with the node of the standard expression on the syntax tree according to the correspondence table;

[0090] Step E03) Convert the syntax tree into a database operation statement composed of standard expressions.

[0091] The standard expression auxiliary generation method can quickly convert an existing SQL statement of a certain type of database into a standard expression, and realize the rapid construction of the standard expression.

[0092] On the other hand, after receiving the database operation statement composed of the standard expression, the embodiment performs a statement verification step. The statement verification includes the following steps:

[0093] The database operation statement is subjected to syntax verification using a pre-established syntax verification rule. If the syntax verification rule is not met, it is determined that the verification is not passed, and an alarm is issued. If the syntax verification rule is met, it is determined that the syntax verification is passed, and an execution verification is performed.

[0094] The execution time of the database operation statement is predicted using a pre-established execution time prediction rule. If the predicted execution time exceeds a preset threshold, it is determined that the execution verification is not passed, and an alarm is issued. Otherwise, if the predicted execution time does not exceed the preset threshold, it is determined that the execution verification is passed.

[0095] On the other hand, the embodiment provides a specific method for establishing a syntax verification rule, which includes:

[0096] The checking rule for each keyword includes an expression checking rule and a parameter value checking rule, the expression checking rule records an expression that the keyword needs to be associated with, and the parameter value checking rule records a value range of a parameter of the associated expression;

[0097] Each keyword of the database operation statement is compared with the corresponding keyword checking rule respectively, if the keyword is not associated with the associated expression recorded by the expression checking rule or the parameter of the associated expression is out of the value range, it is determined that the syntax verification of the database operation statement fails, otherwise, if the keyword is associated with the associated expression recorded by the expression checking rule and the parameter of the associated expression is in the value range, it is determined that the syntax verification of the database operation statement passes. Through the statement verification step, the SQL statement that does not meet the preset verification rule is filtered out, and the execution efficiency of the SQL statement is improved.

[0098] The expression checking rule is that the keyword "SELECT" needs to be associated with the "WHERE condition" expression, if the keyword "SELECT" is not associated with the "WHERE condition" expression, the database operation statement will not pass the syntax verification. The keyword "SELECT" is associated with the "WHERE condition" expression and also associated with the "LIMIT N" expression, then it is checked whether the value of N is less than 10000, if the value of N is greater than 1000, it is determined that the syntax verification fails. Through checking whether the preset expression is associated or the parameter of the associated expression is out of the value range, the checking of the database operation statement is realized.

[0099] On the other hand, the embodiment provides a method for establishing an execution time consumption prediction rule, please refer to the attached Figure 6 , comprising:

[0100] Step F01) respectively associating time consumption values with the conditional expression, the inline expression, the outer associated expression and the sorting expression, the time consumption value of the conditional expression is a negative value, and the time consumption values of the inline expression, the outer associated expression and the sorting expression are positive values;

[0101] Step F02) listing the conditional expression, the inline expression, the outer associated expression and the sorting expression of the database operation statement;

[0102] Step F03) adding the time consumption values of the conditional expression, the inline expression, the outer join expression and the sorting expression as the predicted value of the execution time consumption of the database operation statement. The conditional expression shows the condition rule of the data selection of the SQL statement, when the conditional expression exists, the selected data will be limited, and the time consumption of the SQL statement will be reduced. When the SQL statement does not have the conditional expression, it indicates that the SQL statement will consume more time. The inline expression, the outer join expression and the sorting expression will take a long time to complete, especially the inline expression and the outer join expression will significantly increase the execution time consumption of the SQL statement. The embodiment predicts the execution time consumption of the SQL statement by executing the time consumption prediction rule, intercepts the SQL statement with high time consumption, and avoids the database from being blocked.

[0103] The above merely illustrates the specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and those skilled in the art should understand that the present application includes but is not limited to the contents described in the above specific embodiments and the drawings. Any modification without deviating from the functional and structural principles of the present application will be included in the scope of the claims.

Claims

1. A database-independent method for generating SQL statements, comprising the steps of: registering standard expressions to establish a correspondence table of SQL expressions of different database types and standard expressions; receiving a database operation statement composed of standard expressions; establishing a syntax tree of the database operation statement; replacing nodes of standard expressions with nodes of SQL expressions of corresponding database types on the syntax tree according to the correspondence table; converting the syntax tree into an SQL statement; submitting the SQL statement to a database for execution to obtain a database response; and feeding back the database response to a user; wherein the correspondence table comprises a keyword correspondence table and a node correspondence table, and the method for establishing the correspondence table comprises: establishing syntax tree nodes of each group of SQL expressions and corresponding standard expressions; if the structure of a syntax tree node of an SQL expression is different from the structure of a syntax tree node of a standard expression, associating the structure of the syntax tree node of the SQL expression with the structure of the syntax tree node of the corresponding standard expression and storing them in the node correspondence table; and if the structure of a syntax tree node of an SQL expression is the same as the structure of a syntax tree node of a standard expression, associating a keyword of the SQL expression with a keyword of the standard expression and storing them in the keyword correspondence table; and the method for replacing nodes of standard expressions with nodes of SQL expressions on a syntax tree comprises: traversing each node of the syntax tree; if a node keyword matches a record in the keyword correspondence table, replacing the node keyword with the keyword in the record in the keyword correspondence table; and if a node keyword matches a record in the node correspondence table, replacing the node with the syntax tree node structure in the record in the node correspondence table. 2.The database-independent method for generating SQL statements according to claim 1, wherein the method for registering standard expressions comprises: listing SQL expressions of multiple database types; dividing SQL expressions of the same function into a group; and registering a standard expression for each group of expressions, wherein the standard expression comprises an operation word and a plurality of parameter placeholders, the operation word of the standard expression is globally unique, and the plurality of parameter placeholders correspond to all parameters of the SQL expressions in the same group. 3.The database-independent method for generating SQL statements according to any one of claims 1 to 2, wherein the method further comprises a standard expression auxiliary generation method for converting an existing SQL expression into a database operation statement composed of standard expressions, and the standard expression auxiliary generation method comprises the steps of: establishing a syntax tree of the existing SQL expression; replacing nodes of the existing SQL expression with nodes of standard expressions on the syntax tree according to the correspondence table; and converting the syntax tree into a database operation statement composed of standard expressions. 4.The database-independent method for generating SQL statements according to any one of claims 1 to 2, wherein ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ After receiving the database operation sentence composed of standard expression, a sentence verification step is performed, which includes the following steps: Syntax verification is performed on the database operation sentence using pre-established syntax verification rules. If the syntax verification rules are not met, the verification is determined to be failed, and an alarm is issued. If the syntax verification rules are met, the syntax verification is determined to be passed, and execution verification is performed. The execution time of the database operation sentence is predicted using pre-established execution time prediction rules. If the predicted execution time exceeds a preset threshold, the execution verification is determined to be failed, and an alarm is issued. Otherwise, if the predicted execution time does not exceed the preset threshold, the execution verification is determined to be passed.

5. The database-independent SQL sentence generation method of claim 4, wherein the method for establishing syntax verification rules comprises: setting a check rule for each keyword, the check rule including an expression check rule and a parameter value check rule, the expression check rule recording an expression to be used with the keyword, and the parameter value check rule recording a value range of a parameter of the used expression; comparing each keyword of the database operation sentence with the corresponding keyword check rule, respectively. If the keyword does not use the expression recorded in the expression check rule or the parameter of the used expression exceeds the value range, the syntax verification of the database operation sentence is determined to be failed. Otherwise, if the keyword uses the expression recorded in the expression check rule and the parameter of the used expression is within the value range, the syntax verification of the database operation sentence is determined to be passed.

6. The database-independent SQL sentence generation method of claim 4, wherein the method for establishing execution time prediction rules comprises: associating a time consumption value with a condition expression, an inline expression, an outlin expression, and a sorting expression, respectively, the time consumption value of the condition expression being a negative value, and the time consumption values of the inline expression, the outlin expression, and the sorting expression being positive values; listing the condition expression, the inline expression, the outlin expression, and the sorting expression of the database operation sentence; adding the time consumption values corresponding to the condition expression, the inline expression, the outlin expression, and the sorting expression to obtain a predicted value of the execution time of the database operation sentence. ​ ​

Citation Information

Patent Citations

  • Database query system

    US20160063063A1