Database maintenance method and apparatus, electronic device, and readable storage medium
By performing category and pattern analysis on the SQL statements audited in the database, replacing sensitive field values, and recording them in a summary record table, the maintenance challenges of the database under frequent access were solved, achieving efficient maintenance and improved security.
Patent Information
- Application Number
- CN202310697858.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-13
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2043-06-13
AI Technical Summary
In existing technologies, when databases are frequently accessed, the number of audited SQL statements is enormous and varied, making it difficult to analyze and maintain them effectively, and also making it impossible to effectively trace the risk of sensitive information leakage.
By obtaining audited SQL statements, determining their categories and patterns, and replacing sensitive field values according to preset rules, the results are recorded in a summary record table to achieve database maintenance and security enhancement.
It enables efficient database maintenance, protects sensitive information from leakage, improves database security and auditing efficiency, and saves storage space.
Smart Images

Figure CN116662548B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and specifically to a database maintenance method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] Databases are widely used in social production and economic activities. The rapid development of the Internet has enhanced the value and accessibility of database information, but it has also greatly increased the security risks to databases from both internal and external sources, such as unauthorized operations and malicious intrusions that lead to the theft and leakage of confidential information, which cannot be effectively traced afterward.
[0003] Database auditing (DBAudit) centers on security incidents and is based on comprehensive and precise auditing. It records database activities on the network in real time, performs granular auditing of database operations for compliance management, and provides real-time alerts for risky behaviors affecting the database. By recording, analyzing, and reporting user access to the database, it helps users generate compliance reports and trace the root causes of incidents. Simultaneously, it uses big data search technology to provide efficient querying of audit reports, pinpointing the causes of incidents for future querying, analysis, and filtering. This strengthens the monitoring and auditing of internal and external database network behavior, improving data asset security.
[0004] Structured Query Language (SQL) is a structured query language used to access, query, update, and manage relational database systems. Commonly used SQL statements include updating, searching, sorting, summing, averaging, finding the maximum and minimum values, etc.
[0005] By analyzing and auditing the SQL statements used by users to operate on the database, we can monitor user behavior and maintain the database based on the audit results, which can effectively improve the database's accessibility and security. Summary of the Invention
[0006] To address the problems in related technologies, this disclosure provides a database maintenance method, characterized by comprising:
[0007] Retrieves the audited Structured Query Language (SQL) statements recorded when auditing a specified database;
[0008] The category to which the audit SQL statement belongs is determined based on the command of the audit SQL statement;
[0009] The audit SQL statements are analyzed to determine their patterns;
[0010] Record the category and pattern of the audit SQL statement in the audit SQL statement summary record table;
[0011] The database is maintained using the summary record table of audit SQL statements.
[0012] According to embodiments of this disclosure, different commands in the audit SQL statements correspond to different categories.
[0013] According to embodiments of this disclosure, the step of analyzing the audit SQL statement to determine the pattern of the audit SQL statement includes:
[0014] According to preset rules, the part of the audit SQL statement related to the field value stored in the specified database is replaced with a specified character or string;
[0015] Retain the portions of the audit SQL statement that are unrelated to the field values stored in the specified database.
[0016] According to embodiments of this disclosure, replacing the portion of the audit SQL statement related to the field value stored in the specified database with a specified character or string includes:
[0017] Replace each Chinese character in the audit SQL statement that relates to the field value stored in the specified database with a first specified character;
[0018] Replace each English word in the audit SQL statement that relates to the field value stored in the specified database with a second specified character;
[0019] Replace each Arabic numeral in the audit SQL statement that relates to the field value stored in the specified database with a third specified character.
[0020] According to embodiments of this disclosure, the portion unrelated to the field values stored in the designated database includes at least one or more of the following:
[0021] Table name; field name; wildcard.
[0022] According to embodiments of this disclosure, recording the category and pattern of the audit SQL statement in the audit SQL statement summary record table includes:
[0023] Based on the category of the audit SQL statement, check whether the category is recorded in the audit SQL statement summary record table;
[0024] If the category is not recorded in the audit SQL statement summary record table, then the category is created in the audit SQL statement summary record table and the category to which the audit SQL statement belongs and the pattern of the audit SQL statement are recorded.
[0025] If the category is recorded in the audit SQL statement summary record table, then check whether the pattern of the audit SQL statement has been recorded under the category;
[0026] If the audit SQL statement pattern is not recorded under the category, then the audit SQL statement pattern is recorded under the category; otherwise, the audit SQL statement pattern is not recorded.
[0027] Secondly, this disclosure provides a database maintenance apparatus, including:
[0028] The acquisition module is configured to acquire audit Structured Query Language (SQL) statements recorded when auditing a specified database.
[0029] The first determining module is configured to determine the category to which the audit SQL statement belongs based on the command of the audit SQL statement;
[0030] The second determining module is configured to analyze the audit SQL statement to determine the pattern of the audit SQL statement;
[0031] The recording module is configured to record the category to which the audit SQL statement belongs and the pattern of the audit SQL statement in the audit SQL statement summary record table;
[0032] The maintenance module is configured to maintain the database using the audit SQL statement summary record table.
[0033] Thirdly, embodiments of this disclosure provide an electronic device including a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method as described in the first aspect.
[0034] Fourthly, this disclosure provides a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the method described in the first aspect.
[0035] Fifthly, this disclosure provides a computer program product including computer instructions that, when executed by a processor, implement the steps of the method described in the first aspect.
[0036] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0037] Other features, objects, and advantages of this disclosure will become more apparent from the following detailed description of non-limiting embodiments, taken in conjunction with the accompanying drawings. In the drawings:
[0038] Figure 1 A flowchart illustrating a database maintenance method according to an embodiment of the present disclosure is shown.
[0039] Figure 2 A flowchart illustrating a database maintenance method according to another embodiment of the present disclosure is shown.
[0040] Figure 3 A flowchart illustrating a database maintenance method according to yet another embodiment of the present disclosure is shown.
[0041] Figure 4 A flowchart illustrating a database maintenance method according to another embodiment of the present disclosure is shown.
[0042] Figure 5 A structural block diagram of a database maintenance apparatus according to an embodiment of the present disclosure is shown.
[0043] Figure 6 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0044] Figure 7 A schematic diagram of the structure of a computer system suitable for implementing the method according to embodiments of the present disclosure is shown. Detailed Implementation
[0045] In the following, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings to enable those skilled in the art to readily implement them. Furthermore, for clarity, portions unrelated to the description of exemplary embodiments have been omitted from the drawings.
[0046] In this disclosure, it should be understood that terms such as “comprising” or “having” are intended to indicate the presence of features, figures, steps, behaviors, components, parts or combinations thereof disclosed in this specification, and are not intended to exclude the possibility of the presence or addition of one or more other features, figures, steps, behaviors, components, parts or combinations thereof.
[0047] It should also be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0048] In this disclosure, any operation involving the acquisition of user information or user data, or the display of user information or user data to others, is an operation authorized or confirmed by the user, or actively selected by the user.
[0049] As mentioned earlier, databases are widely used in social production and economic activities. The rapid development of the Internet has enhanced the value and accessibility of database information, but it has also greatly increased the security risks to databases from both internal and external sources, such as unauthorized operations and malicious intrusions that lead to the theft and leakage of confidential information, which cannot be effectively traced afterward.
[0050] Database auditing (DBAudit) centers on security incidents and is based on comprehensive and precise auditing. It records database activities on the network in real time, performs granular auditing of database operations for compliance management, and provides real-time alerts for risky behaviors affecting the database. By recording, analyzing, and reporting user access to the database, it helps users generate compliance reports and trace the root causes of incidents. Simultaneously, it uses big data search technology to provide efficient querying of audit reports, pinpointing the causes of incidents for future querying, analysis, and filtering. This strengthens the monitoring and auditing of internal and external database network behavior, improving data asset security.
[0051] Structured Query Language (SQL) is a structured query language used to access, query, update, and manage relational database systems. Commonly used SQL statements include updating, searching, sorting, summing, averaging, finding the maximum and minimum values, etc.
[0052] Auditing the SQL statements used by users to operate on the database allows for monitoring of user behavior and enables database maintenance based on the audit results, effectively improving database accessibility and security.
[0053] However, when the database is accessed frequently, the number of SQL statements that need to be audited (also known as "audit SQL statements") is huge and varied. Therefore, an effective means is needed to preprocess them so that subsequent analysis and statistics can more easily locate the key points that need maintenance and improvement.
[0054] To address the aforementioned technical problems, this application discloses a database maintenance method, comprising: obtaining audit structured query language (SQL) statements recorded during the audit of a specified database; determining the category of the audit SQL statements based on their commands; analyzing the audit SQL statements to determine their patterns; recording the category and pattern of the audit SQL statements in an audit SQL statement summary record table; and using the audit SQL statement summary record table to maintain the database. This disclosure, by determining the category and pattern of the obtained audit structured query language (SQL) statements, categorizing them, replacing specified field values according to preset rules, and recording them in a summary record table, allows for targeted maintenance based on the content of the summary record table during database maintenance, while also preventing the leakage of sensitive information and protecting information security.
[0055] Figure 1 A flowchart illustrating a database maintenance method according to an embodiment of the present disclosure is shown. Figure 1 As shown, the database maintenance method includes the following steps S101-S105:
[0056] In step S101, the audit structured query language (SQL) statements recorded when auditing the specified database are obtained;
[0057] In step S102, the category to which the audit SQL statement belongs is determined according to the command of the audit SQL statement;
[0058] In step S103, the audit SQL statement is analyzed to determine the pattern of the audit SQL statement;
[0059] In step S104, the category to which the audit SQL statement belongs and the pattern of the audit SQL statement are recorded in the audit SQL statement summary record table;
[0060] In step S105, the database is maintained using the audit SQL statement summary record table.
[0061] According to the embodiments of this disclosure, different commands of the audit SQL statements correspond to different categories. Audit SQL statements are categorized based on the different functions they perform. Examples include: update statements, search statements, sorting statements, summation statements, average calculation statements, maximum value calculation statements, minimum value calculation statements, etc.
[0062] Figure 2 A flowchart illustrating a database maintenance method according to another embodiment of this disclosure is shown. Figure 2 As shown, the analysis of the audit SQL statement to determine its pattern includes:
[0063] In step S1031, according to preset rules, the part of the audit SQL statement related to the field value stored in the specified database is replaced with a specified character or string;
[0064] In step S1032, the portion of the audit SQL statement that is unrelated to the field values stored in the specified database is retained.
[0065] In this disclosure, the preset rules include desensitization rules. The SQL statements used by users to operate on the database contain a large amount of information related to field values stored in the database, such as names, addresses, accounts, passwords, etc. Desensitization rules can replace this information with specified characters or strings, thereby preventing the leakage of sensitive information.
[0066] At the same time, retain the parts of the audit SQL statement that are not related to the field values stored in the specified database. For example, retain the SQL statement command (e.g., “select”, “update”, etc.), the name of the data table operated on (e.g., “product price list”, “January sales statistics table”, etc.), and the data field names (e.g., “product name”, “price”, “sales volume”, etc.).
[0067] The de-sensitized audit SQL statements do not contain sensitive information, but still reflect the type and object of the user's operation (e.g., the data table and data fields operated on). By replacing the parts of the audit SQL statement related to the field values stored in the specified database with specified characters or strings according to preset rules, while retaining the parts of the audit SQL statement unrelated to the field values stored in the specified database, a pattern of audit SQL statements can be obtained. This pattern hides the sensitive information in the SQL statement but retains information related to the type and object of the user's operation.
[0068] When users perform the same operation on the same data field in the same data table, even if the values of the data fields involved are different, the corresponding audit SQL statement pattern is the same. By storing the audit SQL statement pattern instead of the actual audit SQL statement, sensitive information is protected while pre-analysis and statistics of audit SQL statements are achieved, and a significant amount of storage space is saved.
[0069] Figure 3 A flowchart illustrating a database maintenance method according to yet another embodiment of the present disclosure is shown. Figure 3 As shown, replacing the portion of the audit SQL statement related to the field values stored in the specified database with specified characters or strings includes:
[0070] In step S10311, each Chinese character in the audit SQL statement related to the field value stored in the specified database is replaced with a first specified character;
[0071] In step S10312, each English word in the audit SQL statement that is related to the field value stored in the specified database is replaced with a second specified character;
[0072] In step S10313, each Arabic numeral in the audit SQL statement related to the field value stored in the specified database is replaced with a third specified character.
[0073] In this disclosed method, based on preset rules, field values can be replaced with specified characters or strings of different types according to their different types. For example, in a bank database, the recorded SQL statements may involve sensitive information such as user name, account number, password, and account opening location. This sensitive information may be composed of Chinese characters, Arabic numerals, and English words, respectively. Replacing this information with different specified characters or strings can, while achieving information desensitization and confidentiality, reveal the attributes of the replaced information, making it easier to determine the pattern of the SQL statements and categorize them.
[0074] According to embodiments of this disclosure, the first specified character, the second specified character, and the third specified character are characters that are not included in the field values stored in the specified database. For example, if the field values stored in the specified database do not include "^", "~", and ">", then the first specified character can be "^", the second specified character can be "~", and the third specified character can be ">", that is, replacing all Chinese characters in the SQL statement with "^", all English words with "~", and all Arabic numerals with ">".
[0075] According to embodiments of this disclosure, the portion unrelated to the field values stored in the specified database includes at least one or more of the following: table name; field name; wildcard.
[0076] Figure 4 A flowchart illustrating a database maintenance method according to another embodiment of the present disclosure is shown. Figure 4 As shown, recording the category and pattern of the audit SQL statement in the audit SQL statement summary record table includes:
[0077] In step S1041, based on the category of the audit SQL statement, it is checked whether the category is recorded in the audit SQL statement summary record table;
[0078] In step S1042, if the category is not recorded in the audit SQL statement summary record table, the category is created in the audit SQL statement summary record table and the category to which the audit SQL statement belongs and the pattern of the audit SQL statement are recorded.
[0079] In step S1043, if the category is recorded in the audit SQL statement summary record table, then check whether the audit SQL statement pattern has been recorded under the category;
[0080] In step S1044, if the audit SQL statement pattern is not recorded under the category, then the audit SQL statement pattern is recorded under the category; otherwise, the audit SQL statement pattern is not recorded.
[0081] According to embodiments of this disclosure, for each audit SQL statement pattern, information such as the number of times it was used, the time, the source address, and the number of times the return value was incorrect is recorded. In this disclosure, a summary record table is used to record the categories and patterns of audit SQL statements. SQL statements of the same category or pattern are merged and statistically analyzed. Finally, based on the content recorded in the summary record table, the SQL statements are audited and analyzed. Based on the summary record table, the patterns of audit SQL statements can be classified and statistically analyzed, and information such as their usage frequency, number of errors, and error locations can be analyzed, making database maintenance more targeted, improving database auditing efficiency, and preventing the leakage of sensitive information.
[0082] For example, for each audit SQL statement pattern, it is possible to statistically analyze the number of times it is used by users, peak periods, number of errors, number of malicious attacks, and the source address of malicious attacks, thereby quickly locating data tables and data fields that are frequently accessed, prone to errors, or vulnerable to attacks. This makes it easier for maintenance personnel to make targeted improvements to database access performance or security.
[0083] According to embodiments of this disclosure, the method described above can be executed simultaneously with the collection of audit SQL statements, updating the audit SQL statement summary record table in real time. Compared to the method of periodically summarizing and analyzing audit SQL statements after collection, the real-time processing according to embodiments of this disclosure has higher timeliness, effectively saves storage and computing resources, and is more conducive to timely detection and handling of problems and risks that occur during database access.
[0084] Figure 5 A structural block diagram of a database maintenance apparatus according to an embodiment of the present disclosure is shown. This apparatus can be implemented as part or all of an electronic device through software, hardware, or a combination of both.
[0085] like Figure 5As shown, the collateral risk level prediction setting 500 includes an acquisition module 510, a first determination module 520, a second determination module 530, a recording module 540, and a maintenance module 550.
[0086] The acquisition module 510 is configured to acquire audit structured query language (SQL) statements recorded when auditing a specified database.
[0087] The first determining module 520 is configured to determine the category to which the audit SQL statement belongs based on the command of the audit SQL statement;
[0088] The second determining module 530 is configured to analyze the audit SQL statement to determine the pattern of the audit SQL statement;
[0089] The recording module 540 is configured to record the category to which the audit SQL statement belongs and the pattern of the audit SQL statement in the audit SQL statement summary record table;
[0090] Maintenance module 550 is configured to maintain the database using the audit SQL statement summary record table.
[0091] According to the embodiments of this disclosure, different commands of the audit SQL statements correspond to different categories. Audit SQL statements are categorized based on the different functions they perform. Examples include: update statements, search statements, sorting statements, summation statements, average calculation statements, maximum value calculation statements, minimum value calculation statements, etc.
[0092] According to embodiments of this disclosure, the second determining module includes:
[0093] The replacement submodule is configured to replace the part of the audit SQL statement related to the field value stored in the specified database with a specified character or string according to a preset rule;
[0094] The retention submodule is configured to retain portions of the audit SQL statement that are unrelated to field values stored in the specified database.
[0095] In this disclosure, the preset rules include desensitization rules. The SQL statements used by users to operate on the database contain a large amount of information related to field values stored in the database, such as names, addresses, accounts, passwords, etc. Desensitization rules can replace this information with specified characters or strings, thereby preventing the leakage of sensitive information.
[0096] At the same time, retain the parts of the audit SQL statement that are not related to the field values stored in the specified database. For example, retain the SQL statement command (e.g., “select”, “update”, etc.), the name of the data table operated on (e.g., “product price list”, “January sales statistics table”, etc.), and the data field names (e.g., “product name”, “price”, “sales volume”, etc.).
[0097] The de-sensitized audit SQL statements do not contain sensitive information, but still reflect the type and object of the user's operation (e.g., the data table and data fields operated on). By replacing the parts of the audit SQL statement related to the field values stored in the specified database with specified characters or strings according to preset rules, while retaining the parts of the audit SQL statement unrelated to the field values stored in the specified database, a pattern of audit SQL statements can be obtained. This pattern hides the sensitive information in the SQL statement but retains information related to the type and object of the user's operation.
[0098] When users perform the same operation on the same data field in the same data table, even if the values of the data fields involved are different, the corresponding audit SQL statement pattern is the same. By storing the audit SQL statement pattern instead of the actual audit SQL statement, sensitive information is protected while pre-analysis and statistics of audit SQL statements are achieved, and a significant amount of storage space is saved.
[0099] According to embodiments of this disclosure, replacing the portion of the audit SQL statement related to the field value stored in the specified database with a specified character or string includes:
[0100] Replace each Chinese character in the audit SQL statement that relates to the field value stored in the specified database with a first specified character;
[0101] Replace each English word in the audit SQL statement that relates to the field value stored in the specified database with a second specified character;
[0102] Replace each Arabic numeral in the audit SQL statement that relates to the field value stored in the specified database with a third specified character.
[0103] In this disclosed method, based on preset rules, field values can be replaced with specified characters or strings of different types according to their different types. For example, in a bank database, the recorded SQL statements may involve sensitive information such as user name, account number, password, and account opening location. This sensitive information may be composed of Chinese characters, Arabic numerals, and English words, respectively. Replacing this information with different specified characters or strings can, while achieving information desensitization and confidentiality, reveal the attributes of the replaced information, making it easier to determine the pattern of the SQL statements and categorize them.
[0104] According to embodiments of this disclosure, the first specified character, the second specified character, and the third specified character are characters that are not included in the field values stored in the specified database. For example, if the field values stored in the specified database do not include "^", "~", and ">", then the first specified character can be "^", the second specified character can be "~", and the third specified character can be ">", that is, replacing all Chinese characters in the SQL statement with "^", all English words with "~", and all Arabic numerals with ">".
[0105] According to embodiments of this disclosure, the portion unrelated to the field values stored in the specified database includes at least one or more of the following: table name; field name; wildcard.
[0106] According to an embodiment of this disclosure, the recording module 540 includes:
[0107] The first search submodule is configured to search whether the category of the audit SQL statement is recorded in the audit SQL statement summary record table.
[0108] The first recording submodule is configured to, if the category is not recorded in the audit SQL statement summary record table, create the category in the audit SQL statement summary record table and record the category to which the audit SQL statement belongs and the pattern of the audit SQL statement.
[0109] The second search submodule is configured to search whether the audit SQL statement pattern has been recorded under the category if the category is recorded in the audit SQL statement summary record table.
[0110] The second recording submodule is configured to record the audit SQL statement pattern under the category if the audit SQL statement pattern is not recorded under the category, otherwise the audit SQL statement pattern is not recorded.
[0111] According to embodiments of this disclosure, for each audit SQL statement pattern, information such as the number of times it was used, the time, the source address, and the number of times the return value was incorrect is recorded. In this disclosure, a summary record table is used to record the categories and patterns of audit SQL statements. SQL statements of the same category or pattern are merged and statistically analyzed. Finally, based on the content recorded in the summary record table, the SQL statements are audited and analyzed. Based on the summary record table, the patterns of audit SQL statements are classified and statistically analyzed, and information such as their usage frequency, number of errors, and error locations are analyzed, making database maintenance more targeted, improving database auditing efficiency, and preventing the leakage of sensitive information.
[0112] For example, for each audit SQL statement pattern, it is possible to statistically analyze the number of times it is used by users, peak periods, number of errors, number of malicious attacks, and the source address of malicious attacks, thereby quickly locating data tables and data fields that are frequently accessed, prone to errors, or vulnerable to attacks. This makes it easier for maintenance personnel to make targeted improvements to database access performance or security.
[0113] According to embodiments of this disclosure, the method described above can be executed simultaneously with the collection of audit SQL statements, updating the audit SQL statement summary record table in real time. Compared to the method of periodically summarizing and analyzing audit SQL statements after collection, the real-time processing according to embodiments of this disclosure has higher timeliness, effectively saves storage and computing resources, and is more conducive to timely detection and handling of problems and risks that occur during database access.
[0114] This disclosure also discloses an electronic device. Figure 6 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0115] like Figure 6 As shown, the electronic device includes a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method according to embodiments of the present disclosure.
[0116] According to embodiments of this disclosure, a database maintenance method is characterized by comprising:
[0117] Retrieves the audited Structured Query Language (SQL) statements recorded when auditing a specified database;
[0118] The category to which the audit SQL statement belongs is determined based on the command of the audit SQL statement;
[0119] The audit SQL statements are analyzed to determine their patterns;
[0120] Record the category and pattern of the audit SQL statement in the audit SQL statement summary record table;
[0121] The database is maintained using the summary record table of audit SQL statements.
[0122] According to embodiments of this disclosure, different commands in the audit SQL statements correspond to different categories.
[0123] According to an embodiment of this disclosure, the step of analyzing the audit SQL statement to determine the pattern of the audit SQL statement includes: replacing the part of the audit SQL statement related to the field value stored in the specified database with a specified character or string according to a preset rule; and retaining the part of the audit SQL statement unrelated to the field value stored in the specified database.
[0124] According to embodiments of this disclosure, replacing the portion of the audit SQL statement related to the field value stored in the specified database with a specified character or string includes: replacing each Chinese character in the audit SQL statement related to the field value stored in the specified database with a first specified character; replacing each English word in the audit SQL statement related to the field value stored in the specified database with a second specified character; and replacing each Arabic numeral in the audit SQL statement related to the field value stored in the specified database with a third specified character.
[0125] According to embodiments of this disclosure, the portion unrelated to the field values stored in the specified database includes at least one or more of the following: table name; field name; wildcard.
[0126] According to an embodiment of this disclosure, recording the category and pattern of the audit SQL statement in the audit SQL statement summary record table includes: checking whether the category is recorded in the audit SQL statement summary record table; if the category is not recorded in the audit SQL statement summary record table, creating the category and recording the category and pattern of the audit SQL statement in the audit SQL statement summary record table; if the category is recorded in the audit SQL statement summary record table, checking whether the pattern of the audit SQL statement is already recorded under the category; if the pattern of the audit SQL statement is not recorded under the category, recording the pattern of the audit SQL statement under the category, otherwise not recording the pattern of the audit SQL statement.
[0127] Figure 7A schematic diagram of the structure of a computer system suitable for implementing the method according to embodiments of the present disclosure is shown.
[0128] like Figure 4 As shown, the computer system includes a processing unit that can execute various methods described above based on a program stored in a read-only memory (ROM) or a program loaded from a storage portion into a random access memory (RAM). The RAM also stores various programs and data required for the operation of the computer system. The processing unit, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.
[0129] The following components are connected to the I / O interface: input sections including keyboards, mice, etc.; output sections including cathode ray tubes (CRTs), liquid crystal displays (LCDs), and speakers; storage sections including hard disks, etc.; and communication sections including network interface cards such as LAN cards and modems. The communication section performs communication processes via a network such as the Internet. Drives are also connected to the I / O interface as needed. Removable media, such as disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on the drive as needed so that computer programs read from them can be installed into the storage section as needed. The processing unit can be implemented as a CPU, GPU, TPU, FPGA, NPU, etc.
[0130] In particular, according to embodiments of this disclosure, the methods described above can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program containing program code for performing the methods described above. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium.
[0131] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0132] The units or modules described in the embodiments of this disclosure can be implemented in software or programmable hardware. The described units or modules can also be located in a processor, and the names of these units or modules do not necessarily constitute a limitation on the unit or module itself.
[0133] In another aspect, this disclosure also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the electronic device or computer system described above; or it may be a standalone computer-readable storage medium not assembled into a device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to perform the methods described in this disclosure.
[0134] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
Claims
1. A database maintenance method, comprising: obtaining an audit structured query language (SQL) statement recorded when auditing a specified database; determining a category to which the audit SQL statement belongs according to a command of the audit SQL statement; analyzing the audit SQL statement to determine a pattern of the audit SQL statement, including: replacing each Chinese character in the audit SQL statement related to a field value stored in the specified database with a first specified character; replacing each English word in the audit SQL statement related to the field value stored in the specified database with a second specified character; replacing each Arabic numeral in the audit SQL statement related to the field value stored in the specified database with a third specified character; and retaining a part of the audit SQL statement unrelated to the field value stored in the specified database; recording the category to which the audit SQL statement belongs and the pattern of the audit SQL statement in an audit SQL statement summary record table, wherein the audit SQL statement summary record table is used to record the category to which the audit SQL statement belongs and the pattern of the audit SQL statement, so as to perform a combined statistics on SQL statements of the same pattern, the combined statistics including counting a number of times that each pattern of the audit SQL statement is used by a user, a peak time period, a number of errors, a number of malicious attacks, and a source address of a malicious attack; maintaining the database using the audit SQL statement summary record table.
2. The method of claim 1, wherein, Different commands of the audit SQL statement correspond to different categories.
3. The method of claim 1, wherein, The part of the audit SQL statement unrelated to the field value stored in the specified database includes at least one or more of the following: a data table name; a field name; and a wildcard. 4.The method of claim 1, wherein the recording the category to which the audit SQL statement belongs and the pattern of the audit SQL statement in the audit SQL statement summary record table comprises: looking up whether the category is recorded in the audit SQL statement summary record table according to the category of the audit SQL statement; if the category is not recorded in the audit SQL statement summary record table, establishing the category in the audit SQL statement summary record table and recording the category to which the audit SQL statement belongs and the pattern of the audit SQL statement; if the category is recorded in the audit SQL statement summary record table, looking up whether the pattern of the audit SQL statement has been recorded under the category; if the pattern of the audit SQL statement is not recorded under the category, recording the pattern of the audit SQL statement under the category, otherwise, not recording the pattern of the audit SQL statement.
5. A database maintenance apparatus characterized by comprising: comprises: an obtaining module configured to obtain an audit structured query language (SQL) statement recorded when auditing a specified database; a first determining module configured to determine a category to which the audit SQL statement belongs according to a command of the audit SQL statement; The second determining module is configured to analyze the audit SQL statement to determine the pattern of the audit SQL statement, including: replacing each Chinese character in the audit SQL statement related to the field value stored in the specified database with a first specified character; replacing each English word in the audit SQL statement related to the field value stored in the specified database with a second specified character; replacing each Arabic numeral in the audit SQL statement related to the field value stored in the specified database with a third specified character; and retaining the part of the audit SQL statement unrelated to the field value stored in the specified database; The recording module is configured to record the category to which the audit SQL statement belongs and the pattern of the audit SQL statement in an audit SQL statement summary record table, wherein the audit SQL statement summary record table is used to record the category to which the audit SQL statement belongs and the pattern of the audit SQL statement, so as to perform consolidated statistics on the SQL statements of the same pattern, the consolidated statistics including counting the number of times that the pattern of each audit SQL statement is used by a user, a peak period, the number of errors, the number of malicious attacks, and a malicious attack source address; The maintenance module is configured to maintain the database using the audit SQL statement summary record table.
6. An electronic device, comprising: The computer program product comprises computer instructions, and the computer instructions are executed by the processor to implement the method steps of any one of claims 1-4.
7. A computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are executed by the processor to implement the method steps of any one of claims 1-4.
8. A computer program product comprising computer instructions, and the computer instructions are executed by the processor to implement the method steps of any one of claims 1-4.
Citation Information
Patent Citations
Data query method, server and storage medium
CN111651472A
MySQL database protection method based on security agent
CN111695152A