Audit Method and Device for SQL Statements of Data Changes
By grouping, arranging and syntax abstracting the data change SQL files, and combining preset audit rules, the review of SQL statements is automatically completed, which solves the problem of unstable manual audit quality, and realizes efficient and flexible SQL statement review, ensuring the correctness of changes.
Patent Information
- Application Number
- CN202111385285.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-22
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2041-11-22
AI Technical Summary
In the prior art, the audit of changes of SQL statements relies on manual audits, resulting in uneven audit quality and large workload, which is prone to missed audits and missed audits, and it is difficult to ensure the correctness of SQL changes.
By grouping statements, arranging statements, syntax abstract processing and equivalent statement extraction of data change SQL files, combining preset audit rules, the review of SQL statements is automatically completed, and the manual audit process is simulated to improve audit efficiency and quality.
It realizes efficient and flexible SQL statement review, avoids missed and misinterpreted reviews in manual review, improves audit efficiency and quality, and ensures the correctness of SQL changes.
Smart Images

Figure CN114065288B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data change, and particularly to a method and device for auditing SQL statements for data change. Background Art
[0002] In today's IT industry, databases are widely used to store various types of data. When practitioners change the data in the database, due to the lack of rigor in SQL (Structured Query Language) statements, there are often phenomena such as data operation failures, the scope of changed data being enlarged, unrelated data being modified or deleted by mistake. How to ensure the correctness of SQL changes has become an important task in the IT industry. Since data changes usually carry certain business implications, the current SQL auditing for data changes in the IT industry mainly relies on manual auditing. Manual auditing highly depends on the personal capabilities of the auditing positions, and the auditing quality varies; in addition, when there are a large number of SQL statements to be audited, the manual auditing workload is large, and there will be phenomena such as missed auditing and incorrect auditing due to work fatigue of the auditing personnel, and it is difficult to guarantee the auditing effect. Summary of the Invention
[0003] Aiming at the problems existing in the prior art, the main purpose of the embodiments of the present invention is to provide a method and device for auditing SQL statements for data change, so as to improve the SQL auditing efficiency and quality.
[0004] To achieve the above purpose, the embodiments of the present invention provide a method for auditing SQL statements for data change, and the auditing method includes:
[0005] Obtain a data change SQL file, and group the SQL statements according to the access targets corresponding to the SQL statements in the data change SQL file to obtain a plurality of statement auditing groups;
[0006] Arrange the SQL statements in the statement auditing groups according to the data operation types corresponding to the SQL statements in the statement auditing groups;
[0007] Perform syntax abstraction processing on the SQL statements in the statement auditing groups after statement arrangement, and extract equivalent statements from the SQL statements after syntax abstraction processing;
[0008] Use preset auditing rules to perform rule auditing on the equivalent statements in the statement auditing groups to obtain an auditing result.
[0009] Optionally, in an embodiment of the present invention, the performing syntax abstraction processing on the SQL statements in the statement auditing groups after statement arrangement, and extracting equivalent statements from the SQL statements after syntax abstraction processing includes:
[0010] Replace the table field values in the SQL statement with preset abstract values to complete the syntax abstraction process for the SQL statements in the statement review grouping after statement arrangement;
[0011] Perform a repeatability analysis on the data operation types of the SQL statements after replacing the table field values, and classify and extract equivalent statements for the SQL statements with the same repeatability analysis results to obtain equivalent statements.
[0012] Optionally, in an embodiment of the present invention, the rule review of the equivalent statements in the statement review grouping by using the preset review rules includes:
[0013] Perform a syntax check on the equivalent statements in the statement review grouping to obtain a syntax check result;
[0014] According to the data operation type corresponding to the equivalent statement, obtain the review rule corresponding to the data operation type from the preset review rules;
[0015] According to the review rule corresponding to the data operation type, perform a rule review on the equivalent statement to obtain a statement check result.
[0016] Optionally, in an embodiment of the present invention, the review method further includes: obtaining a review result according to the syntax check result and the statement check result.
[0017] An embodiment of the present invention further provides an audit device for data change SQL statements, and the audit device includes:
[0018] An audit grouping module, configured to obtain a data change SQL file, and perform statement grouping according to the access targets corresponding to each SQL statement in the data change SQL file to obtain a plurality of statement review groupings;
[0019] A statement arrangement module, configured to arrange the SQL statements in the statement review grouping according to the data operation types corresponding to each SQL statement in the statement review grouping;
[0020] An equivalent statement module, configured to perform syntax abstraction processing on the SQL statements in the statement review grouping after statement arrangement, and extract equivalent statements from the SQL statements after syntax abstraction processing;
[0021] A rule review module, configured to use the preset review rules to perform rule review on the equivalent statements in the statement review grouping to obtain a review result.
[0022] Optionally, in an embodiment of the present invention, the equivalent statement module includes:
[0023] A syntax abstraction unit for replacing table field values in an SQL statement with preset abstract values to complete syntax abstraction processing on the SQL statements in the statement review grouping after statement arrangement;
[0024] An equivalent statement unit for performing a repetitive analysis of data operation types on the SQL statement after replacing table field values, and classifying and extracting equivalent statements for SQL statements with the same repetitive analysis result to obtain equivalent statements.
[0025] Optionally, in an embodiment of the present invention, the rule review module includes:
[0026] A syntax check unit for performing a syntax check on the equivalent statements in the statement review grouping to obtain a syntax check result;
[0027] A review rule unit for obtaining a review rule corresponding to the data operation type from preset review rules according to the data operation type corresponding to the equivalent statement;
[0028] A statement check unit for performing a rule review on the equivalent statement according to the review rule corresponding to the data operation type to obtain a statement check result.
[0029] Optionally, in an embodiment of the present invention, the rule review module is further configured to obtain a review result according to the syntax check result and the statement check result.
[0030] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the above method when executing the program.
[0031] The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.
[0032] The present invention groups and arranges the SQL statements in the data change SQL file, extracts SQL statements with the same data operation type into equivalent SQL statements, greatly improves the review efficiency, and combines preset review rules for review, making the review process flexible and extensible, and avoiding the phenomena of missed review and wrong review during manual review. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other drawings without creative efforts based on these drawings.
[0034] Figure 1 Flow chart of a method for auditing SQL statements for data changes according to an embodiment of the present invention;
[0035] Figure 2 Flow chart of extracting equivalent statements according to an embodiment of the present invention;
[0036] Figure 3 Flow chart of rule auditing according to an embodiment of the present invention;
[0037] Figure 4 Schematic structural diagram of a system for applying the method for auditing SQL statements for data changes according to an embodiment of the present invention;
[0038] Figure 5 Flow chart of system auditing according to an embodiment of the present invention;
[0039] Figure 6 Internal processing flow chart of the audit grouping unit according to an embodiment of the present invention;
[0040] Figure 7 Schematic structural diagram of an apparatus for auditing SQL statements for data changes according to an embodiment of the present invention;
[0041] Figure 8 Schematic structural diagram of the equivalent statement module according to an embodiment of the present invention;
[0042] Figure 9 Schematic structural diagram of the rule audit module according to an embodiment of the present invention;
[0043] Figure 10 Schematic structural diagram of an electronic device provided by an embodiment of the present invention. Detailed implementation manners
[0044] Embodiments of the present invention provide a method and an apparatus for auditing SQL statements for data changes, which can be used in the financial field and other fields. It should be noted that the method and apparatus for auditing SQL statements for data changes of the present invention can be used in the financial field and can also be used in any field other than the financial field. The application field of the method and apparatus for auditing SQL statements for data changes of the present invention is not limited.
[0045] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0046] Such as Figure 1The figure shows a flowchart of a method for auditing data change SQL statements according to an embodiment of the present invention. The execution subject of the method for auditing data change SQL statements provided by the embodiment of the present invention includes, but is not limited to, a computer. The method shown in the figure includes:
[0047] Step S1, obtain a data change SQL file, and group the SQL statements according to the access targets corresponding to the SQL statements in the data change SQL file to obtain a plurality of statement audit groups.
[0048] Among them, the data change SQL file can be submitted by business personnel, and the data change SQL file includes multiple SQL statements for data change. According to the access targets corresponding to the SQL statements, that is, the table names accessed, the SQL statements are grouped to obtain a plurality of statement audit groups. Specifically, the SQL statements accessing the same table can be included in one statement audit group.
[0049] Further, after obtaining the statement audit groups, allocate the corresponding number of background threads according to the number of statement audit groups. Adopt a multi-threaded method to simultaneously audit and process the SQL statements in each statement audit group.
[0050] Step S2, arrange the SQL statements in the statement audit group according to the data operation types corresponding to the SQL statements in the statement audit group.
[0051] Among them, each SQL statement corresponds to a different data operation type, and the data operation types include Delete, Insert, Update, and Select. Specifically, the SQL statements belonging to the same data operation type in the statement audit group are arranged continuously together, and empty lines are used to separate and distinguish the SQL statements belonging to different data operation types.
[0052] Step S3, perform syntax abstraction processing on the SQL statements in the statement audit group after statement arrangement, and extract equivalent statements from the SQL statements after syntax abstraction processing.
[0053] Among them, after the statement arrangement is completed in each statement audit group, syntax abstraction processing is performed on the SQL statements in the statement audit group. Specifically, syntax abstraction processing is to replace the table field values in the SQL statements with preset abstraction values. After completing the statement abstraction processing, perform a repeatability analysis on each SQL statement, that is, judge the similarity of each SQL statement. If the similarity exceeds the preset threshold, the repeatability analysis result is the same. Classify and extract equivalent statements from the SQL statements with the same repeatability analysis result to obtain equivalent statements.
[0054] Further, SQL statements of the same type are extracted into one equivalent SQL statement. When there is only one SQL statement belonging to a certain data operation type, the equivalent extraction is performed on this single SQL statement alone to obtain an equivalent statement. It can be seen from this that the relationship between the equivalent statement and the actual SQL statement can be one-to-many or one-to-one.
[0055] Step S4: Use a preset review rule to perform a rule review on the equivalent statements in the statement review group to obtain a review result.
[0056] Among them, the review rules can be preset according to different data operation types. For example, if the data operation type is Delete or Update, check whether there is a Where clause in the equivalent SQL statement, etc. Use the review rule corresponding to the data operation type of each SQL statement in the preset review rule to perform a rule review on the equivalent statement, and thus obtain a review result.
[0057] Further, when performing a rule review, first perform a syntax check on the equivalent statement to obtain a syntax check result. Then use the preset review rule to perform a rule review on the equivalent statement to obtain a statement check result. Only when both the syntax check result and the statement check result pass, is this equivalent statement considered to pass the review. If all the equivalent statements in the review group pass the review, it is marked that the review group passes the review. If the equivalent statement fails the syntax check or fails the review of the preset rule, the equivalent statement review fails, and the approval group to which it belongs fails the review.
[0058] As an embodiment of the present invention, as Figure 2 shown, for the SQL statements in the statement review group after statement arrangement, the syntax abstraction process is performed, and the extraction of equivalent statements from the SQL statements after syntax abstraction processing includes:
[0059] Step S21: Replace the table field values in the SQL statement with preset abstraction values to complete the syntax abstraction process for the SQL statements in the statement review group after statement arrangement;
[0060] Step S22: Perform a repeatability analysis of the data operation types on the SQL statement after the replacement of the table field values, and classify and extract equivalent statements for the SQL statements with the same repeatability analysis result to obtain equivalent statements.
[0061] Among them, the syntax abstraction process is to replace the table field values in the SQL statement with preset abstraction values. After completing the statement abstraction process, perform a repeatability analysis on each SQL statement, that is, judge the similarity of each SQL statement. If the similarity exceeds the preset threshold, the repeatability analysis result is the same. Classify and extract equivalent statements for the SQL statements with the same repeatability analysis result to obtain equivalent statements.
[0062] As an embodiment of the present invention, as Figure 3 shown, using the preset audit rules, the rule audit of equivalent statements in the statement audit group includes:
[0063] Step S31, perform a syntax check on the equivalent statements in the statement audit group to obtain a syntax check result;
[0064] Step S32, according to the data operation type corresponding to the equivalent statement, obtain the audit rule corresponding to the data operation type from the preset audit rules;
[0065] Step S33, perform a rule audit on the equivalent statements according to the audit rule corresponding to the data operation type to obtain a statement check result.
[0066] Among them, the audit rules can be preset according to different data operation types, and the equivalent statements are audited using the audit rules corresponding to the data operation types of each SQL statement in the preset audit rules, thereby obtaining the audit result.
[0067] Further, when performing the rule audit, first perform a syntax check on the equivalent statements to obtain a syntax check result. Then use the preset audit rules to perform a rule audit on the equivalent statements to obtain a statement check result.
[0068] As an embodiment of the present invention, the audit method further includes: obtaining a review result according to the syntax check result and the statement check result.
[0069] Among them, only when both the syntax check result and the statement check result are passed, this equivalent statement is considered to pass the audit. If all equivalent statements in the audit group pass the audit, it is marked that the audit group passes the audit. If the equivalent statement fails the syntax check or fails the audit of the preset rules, the equivalent statement audit fails, and the approval group to which it belongs fails the audit.
[0070] The present invention aims at the problems existing in the manual audit of data change SQL, configures different inspection rules for SQL statements of different data operation types, simulates the manual audit method, automatically completes the audit of different SQL statements, and prevents the risk of incorrect data changes. At the same time, by reorganizing the SQL statements in the file to be audited, the SQL statements accessing the same table are used as a statement audit group, and the multi-thread technology is used to concurrently audit the SQL statements of different tables, improving the audit efficiency. On the other hand, aiming at the phenomenon that there are a large number of identical operations in data change SQL statements in real business, for multiple SQL statements with the same data operation in an audit group, an equivalent SQL statement is extracted in an equivalent class manner, and the equivalent statement is used to replace the similar SQL statements for auditing, further improving the SQL audit efficiency.
[0071] As a specific embodiment of the present invention, as Figure 4 shown in the system structure schematic diagram of the method for auditing SQL statements for application data changes in the embodiment of the present invention. The system shown in the figure includes: a data acquisition unit, a data reorganization unit, a concurrent processing unit, an audit grouping processing unit, a result judgment unit, and a result output unit. As Figure 5 shown in the audit flow chart of the system, the specific process is as follows.
[0072] S101, the data acquisition unit receives the data change SQL file submitted by the system user.
[0073] S102, the data reorganization unit rearranges the SQL statements in the SQL file according to the accessed table names and data operation types. The SQL statements accessing the same table are incorporated into one audit grouping. The SQL statements with the same data operation within the same audit grouping are arranged consecutively together, and the SQL statements with different data operations are separated by blank lines. Specifically, the original change SQL file is shown in Table 1, and the split audit groupings are shown in Table 2.
[0074] Table 1
[0075]
[0076] Table 2
[0077]
[0078]
[0079] S103, the concurrent processing unit allocates the corresponding number of background threads according to the number of audit groupings calculated by the data reorganization unit, and simultaneously audits the SQL statements in each audit grouping.
[0080] S104, the audit grouping processing unit extracts equivalent SQL statements using the equivalent class method after syntax abstraction for the SQL statements with the same data operation, and performs syntax checking and rule auditing on each equivalent SQL statement;
[0081] S105, the result judgment unit checks the audit passing situation of all audit groupings to determine the automatic audit result of the current SQL file;
[0082] S106, for the SQL file that passes the audit, the result output unit generates an audit passing report file, and at the same time transfers the SQL file to other systems for subsequent processing; for the SQL file that fails the audit, the result output unit generates an audit failing report file, provides the list of SQL statements that fail the audit and the reasons for non-passing.
[0083] In this embodiment, as Figure 6The following shows the internal processing flow chart of the audit grouping unit. The audit grouping unit is the core processing unit of the system, and the relevant process description is as follows:
[0084] S201, Access the target database to obtain information such as DDL and indexes of the audit grouping access data table. Among them, information such as DDL and indexes is used as a reference for subsequent rule reviews.
[0085] S202, Abstract the syntax of SQL statements with the same data operation type in the audit grouping to extract equivalent SQL statements. Among them, the original SQL is shown in Table 3, the SQL statements after statement abstraction processing are shown in Table 4, and the corresponding relationship between the equivalent statements and the original SQL statements is shown in Table 5.
[0086] Table 3
[0087]
[0088]
[0089] Table 4
[0090]
[0091] Table 5
[0092]
[0093]
[0094] S203, Judge whether the syntax of each equivalent SQL statement in the audit grouping is correct. Construct an abstract syntax tree for the equivalent SQL statement. If the abstract syntax tree can be successfully constructed, the equivalent SQL statement passes the syntax check. Otherwise, the equivalent SQL statement has a syntax error and enters the S108 process.
[0095] S204, According to the data operation type of the equivalent SQL statement, match the preset rules to be audited from the audit rule library, and check rules such as data change range control. The preset audit rules are shown in Table 6, that is, the system rule library.
[0096] Table 6
[0097]
[0098]
[0099] S205, if the data operation type is Delete or Update, check whether the equivalent SQL statement has a WHERE clause. If not, proceed to S108 for processing; if the equivalent SQL has a WHERE clause, continue to check whether the filtering conditions in the WHERE clause of the equivalent SQL contain the primary key field or unique index field of the accessed data table. If not, proceed to S108 for processing; if all matching rules pass the check, mark this equivalent SQL as approved.
[0100] S206, determine whether all equivalent SQL statements within the approval group have passed the review. If there are still unprocessed equivalent SQL statements, repeat the processing of S103 to S105 for the unprocessed equivalent SQL statements in sequence.
[0101] S207, if all equivalent SQL statements within the review group have passed the review, mark this review group as approved.
[0102] S208, if the equivalent SQL fails the syntax check or the review of the preset rules, write the actual SQL statement corresponding to the equivalent SQL into the review failure report file, record the corresponding reasons for failure, and at the same time mark the equivalent SQL statement as not approved and the approval group to which it belongs as not approved.
[0103] In this embodiment, the content corresponding to Tables 3 - 5 is the process of extracting equivalent SQL statements, and the relevant process description is as follows:
[0104] 1) Abstract the syntax of SQL statements with different data operations within the approval group, and uniformly replace the specific values of table fields in the SQL statements with the abstract value ColumnValue.
[0105] 2) Perform repeatability analysis on the SQL statements after replacing the field values, classify the same SQL statements, and extract the same type of SQL statements into one equivalent SQL statement.
[0106] 3) Establish a mapping relationship between the equivalent SQL statement and the actual SQL statement (the SQL statement before replacing the table field values) for the review report to restore the specific SQL statement.
[0107] In this embodiment, Table 6 is a preset SQL review rule library. Each rule in the rule library has clear checkpoints, review passing criteria, adapted SQL statement types, and a "whether to enable" flag. The rules in the enabled state will participate in the check of matching SQL statements. Each rule supports dynamic enabling, disabling, modification, and deletion; at the same time, the rule library supports adding new review rules to adapt to the changes in business development.
[0108] Before automatically auditing the SQL files with data changes submitted by IT practitioners, the present invention first groups them according to the names of the target data tables accessed by the SQL statements, incorporates the SQL statements accessing the same data table into an audit group, and then re-classifies and arranges the SQL statements within the same audit group according to the data operation types (Delete / Insert / Update / Select). The system uses the audit group as the basic processing unit, and utilizes multi-threading technology to simultaneously audit the SQL statements of different tables, splitting one SQL file into multiple small units for parallel processing (one becomes many); on the other hand, for multiple SQL statements with the same operation within an audit group, an equivalent SQL statement is extracted using the syntax abstraction and equivalence class methods, and the audit result of the single equivalent SQL statement is used as the audit result of the SQL statements with the same operation, eliminating the overhead of repeatedly auditing similar SQL statements (many become one). In the rule audit of SQL statements, by presetting that the Delete statement and the Update statement must carry a WHERE clause, and the WHERE clause filtering conditions of the Delete statement and the Update statement must include the table primary key or the table unique index, the scope of the changed data in the SQL statements is audited and controlled, reducing the risk of accidentally changing data in the SQL statements.
[0109] The present invention has the following advantages:
[0110] 1) High audit efficiency. Through multi-threading concurrent technology, one audit SQL file is reorganized and split into N audit groups for parallel processing, and the audit efficiency can be increased by N times; in view of the phenomenon that there are a large number of equivalent operations in the data change SQL statements in real business, the syntax abstraction and equivalence class methods are used to extract the SQL statements with the same operation into one equivalent SQL statement, and only the syntax check and the preset rule check are performed on the equivalent SQL statement, further improving the audit efficiency (compared with the traditional serial-by-piece audit method, the audit efficiency of the present invention can be increased by N*M times, where N is the number of audit groups for parallel processing, and M is the average number of SQL records for equivalent merging).
[0111] 2) The audit rules are flexible and extensible. Users can dynamically enable or disable the preset audit rules; they can also add new audit rules or modify the original audit rules according to the business operation situation.
[0112] 3) The audit quality is guaranteed. The rule-based automatic audit can avoid the phenomena of missed audit and wrong audit that occur during manual audit.
[0113] Such as Figure 7 As shown in the structural schematic diagram of an audit device for data change SQL statements according to an embodiment of the present invention. The audit device shown in the figure includes:
[0114] The review grouping module 10 is used to obtain a data change SQL file, group the SQL statements according to the access targets corresponding to the SQL statements in the data change SQL file, and obtain a plurality of statement review groups;
[0115] The statement arrangement module 20 is used to arrange the SQL statements in the statement review groups according to the data operation types corresponding to the SQL statements in the statement review groups;
[0116] The equivalent statement module 30 is used to perform syntax abstraction processing on the SQL statements in the statement review groups after statement arrangement, and extract equivalent statements from the SQL statements after syntax abstraction processing;
[0117] The rule review module 40 is used to perform rule review on the equivalent statements in the statement review groups by using preset review rules to obtain a review result.
[0118] As an embodiment of the present invention, as Figure 8 shown, the equivalent statement module 30 includes:
[0119] The syntax abstraction unit 31 is used to replace the table field values in the SQL statements with preset abstraction values to complete the syntax abstraction processing on the SQL statements in the statement review groups after statement arrangement;
[0120] The equivalent statement unit 32 is used to perform data operation type repeatability analysis on the SQL statements after table field value replacement, classify the SQL statements with the same repeatability analysis result, and extract equivalent statements to obtain equivalent statements.
[0121] As an embodiment of the present invention, as Figure 9 shown, the rule review module 40 includes:
[0122] The syntax check unit 41 is used to perform syntax check on the equivalent statements in the statement review groups to obtain a syntax check result;
[0123] The review rule unit 42 is used to obtain the review rules corresponding to the data operation types from the preset review rules according to the data operation types corresponding to the equivalent statements;
[0124] The statement check unit 43 is used to perform rule review on the equivalent statements according to the review rules corresponding to the data operation types to obtain a statement check result.
[0125] As an embodiment of the present invention, the rule review module is further used to obtain a review result according to the syntax check result and the statement check result.
[0126] Based on the same application concept as the above-mentioned method for auditing data change SQL statements, the present invention also provides an apparatus for auditing the above-mentioned data change SQL statements. Since the principle of the apparatus for auditing data change SQL statements to solve problems is similar to that of the method for auditing data change SQL statements, the implementation of the apparatus for auditing data change SQL statements can refer to the implementation of the method for auditing data change SQL statements, and the repeated parts will not be described again.
[0127] The present invention groups and arranges the SQL statements in the data change SQL file, extracts the SQL statements with the same data operation type into equivalent SQL statements, greatly improves the auditing efficiency, and performs auditing in combination with the preset auditing rules, making the auditing process flexible and extensible, and avoiding the phenomena of missed auditing and wrong auditing during manual auditing.
[0128] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the program, the above-mentioned method is implemented.
[0129] The present invention also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program for executing the above-mentioned method.
[0130] As Figure 10 shown, the electronic device 600 may further include: a communication module 110, an input unit 120, an audio processing unit 130, a display 160, and a power supply 170. It should be noted that the electronic device 600 does not necessarily have to include Figure 10 all the components shown in Figure 10 ; in addition, the electronic device 600 may further include
[0131] components not shown in Figure 10 ; reference may be made to the prior art.
[0132] Among them, the memory 140 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory, or other suitable devices. The above-mentioned information related to failure can be stored, and in addition, a program for executing relevant information can be stored. And the central processing unit 100 can execute the program stored in the memory 140 to implement information storage or processing, etc.
[0133] The input unit 120 provides an input to the central processing unit 100. The input unit 120 is, for example, a button or a touch input device. The power supply 170 is used to supply power to the electronic device 600. The display 160 is used to display display objects such as images and texts. The display can be, for example, an LCD display, but is not limited thereto.
[0134] The memory 140 can be a solid-state memory, for example, a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It can also be a memory that stores information even when power is off, can be selectively erased and has more data. Examples of such a memory are sometimes referred to as EPROMs, etc. The memory 140 can also be some other type of device. The memory 140 includes a buffer memory 141 (sometimes referred to as a buffer). The memory 140 can include an application / function storage unit 142 that is used to store application programs and function programs or the processes for operating the electronic device 600 by the central processing unit 100.
[0135] The memory 140 can also include a data storage unit 143 that is used to store data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 144 of the memory 140 can include various drivers of the electronic device for communication functions and / or for performing other functions of the electronic device (such as a messaging application, an address book application, etc.).
[0136] The communication module 110 is a transmitter / receiver 110 that transmits and receives signals via the antenna 111. The communication module (transmitter / receiver) 110 is coupled to the central processing unit 100 to provide an input signal and receive an output signal, which can be the same as in the case of a conventional mobile communication terminal.
[0137] Based on different communication technologies, multiple communication modules 110 can be provided in the same electronic device, such as a cellular network module, a Bluetooth module, and / or a wireless local area network module, etc. The communication module (transmitter / receiver) 110 is also coupled to the speaker 131 and the microphone 132 via the audio processor 130 to provide an audio output via the speaker 131 and receive an audio input from the microphone 132, so as to implement normal telecommunication functions. The audio processor 130 can include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor 130 is also coupled to the central processing unit 100, so that recording can be performed on the local machine through the microphone 132, and the sound stored on the local machine can be played through the speaker 131.
[0138] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0139] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0140] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing devices to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0141] These computer program instructions can also be loaded onto a computer or other programmable data processing devices, such that a series of operation steps are executed on the computer or other programmable devices to generate a computer-implemented process, so that the instructions executed on the computer or other programmable devices provide steps for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0142] Specific embodiments of the present invention are used to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only for helping to understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A method for auditing SQL statements for data changes, characterized in that, The audit method includes: Obtain a data change SQL file, and group the SQL statements according to the access targets corresponding to the SQL statements in the data change SQL file to obtain multiple statement audit groups, where the access targets include the names of the data tables accessed; Arrange the SQL statements in the statement audit groups according to the data operation types corresponding to the SQL statements in the statement audit groups; Replace the table field values in the SQL statements with preset abstract values to complete the syntax abstraction process of the SQL statements in the statement audit groups after statement arrangement; Perform a repeatability analysis of the data operation types of the SQL statements after replacing the table field values, and classify and extract equivalent statements for the SQL statements with the same repeatability analysis results to obtain equivalent statements; Use preset audit rules to perform rule audits on the equivalent statements in the statement audit groups to obtain audit results.
2. The auditing method according to claim 1, wherein The use of preset audit rules to perform rule audits on the equivalent statements in the statement audit groups includes: Perform a syntax check on the equivalent statements in the statement audit groups to obtain a syntax check result; According to the data operation types corresponding to the equivalent statements, obtain the audit rules corresponding to the data operation types from the preset audit rules; According to the audit rules corresponding to the data operation types, perform rule audits on the equivalent statements to obtain statement check results.
3. The auditing method according to claim 2, wherein The audit method further includes: obtaining a review result according to the syntax check result and the statement check result.
4. An auditing device for data change SQL statements, characterized in that, The audit device includes: An audit grouping module, configured to obtain a data change SQL file, and group the SQL statements according to the access targets corresponding to the SQL statements in the data change SQL file to obtain multiple statement audit groups, where the access targets include the names of the data tables accessed; A statement arrangement module, configured to arrange the SQL statements in the statement audit groups according to the data operation types corresponding to the SQL statements in the statement audit groups; An equivalent statement module, configured to perform a syntax abstraction process on the SQL statements in the statement audit groups after statement arrangement, and extract equivalent statements from the SQL statements after the syntax abstraction process; A rule audit module, configured to use preset audit rules to perform rule audits on the equivalent statements in the statement audit groups to obtain audit results; The equivalent statement module includes: A syntax abstraction unit, configured to replace the table field values in the SQL statements with preset abstract values to complete the syntax abstraction process of the SQL statements in the statement audit groups after statement arrangement; An equivalent statement unit, configured to perform a repeatability analysis of the data operation types of the SQL statements after replacing the table field values, and classify and extract equivalent statements for the SQL statements with the same repeatability analysis results to obtain equivalent statements.
5. The auditing device according to claim 4, characterized in that, The rule audit module includes: A syntax check unit, configured to perform a syntax check on the equivalent statements in the statement audit groups to obtain a syntax check result; An audit rule unit, configured to obtain the audit rules corresponding to the data operation types from the preset audit rules according to the data operation types corresponding to the equivalent statements; A statement checking unit is configured to perform rule checking on equivalent statements according to auditing rules corresponding to data operation types, so as to obtain statement checking results.
6. The auditing device according to claim 5, characterized in that The rule checking module is further configured to obtain a review result according to the syntax checking result and the statement checking result.
7. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
SQL sentence processing method and system
CN105912594A
SQL statement auditing method and device, storage medium and electronic equipment
CN112783916A