Database abnormal condition detection method and device and storage medium
By identifying the target parameter table in the database and detecting preset statement changes, combined with a cached database and timestamp strategy, the problem of low efficiency in database anomaly detection is solved, achieving fast and real-time anomaly detection.
Patent Information
- Application Number
- CN202511133372.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-13
- Publication Date
- 2025-11-18
AI Technical Summary
Existing technologies have low efficiency in detecting database anomalies, making it difficult to provide real-time feedback and immediate alerts, and also negatively impacting database performance.
By identifying the target parameter table in the database to be tested, detecting preset statement changes based on the target code, updating the number of changes and timestamps in the preset cache database, triggering abnormal status prompts, and using a code interceptor to intercept specific operation code, combined with a strategy of changing number of changes and timestamps, the detection efficiency is improved.
It significantly improves the efficiency of database anomaly detection, reduces data processing volume, quickly locates the source of abnormal operations, improves response speed and real-time performance, and reduces the impact on database performance.
Smart Images

Figure CN120974486A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of financial technology, in particular to a database abnormal condition detection method and device and storage medium. BACKGROUND
[0002] As one of the core components of the business system in the field of financial technology, the database carries massive data storage and processing tasks. The occurrence of database exceptions can easily lead to business failures, trigger production problems, and have a wide impact.
[0003] In the prior art, the load, response time and error log information of the entire database are usually monitored in real time based on professional database performance monitoring tools, or triggers are configured at the database end and the binary log of the database is used for abnormal monitoring. Based on the database performance monitoring tool, the entire database is monitored, which not only consumes a lot of energy, but also has a slow speed, and it is difficult to provide real-time feedback when an abnormal condition occurs. The binary log-based method also cannot achieve immediate alarm for abnormal conditions due to the delay in the generation, transmission and analysis of the log. The trigger-based method consumes high database resources during trigger execution, and may even negatively affect database performance.
[0004] At present, there is no effective solution to the problem of low detection efficiency of database abnormal conditions in the related art. SUMMARY
[0005] The main purpose of the present application is to provide a database abnormal condition detection method, device and storage medium to solve the problem of low detection efficiency of database abnormal conditions in the related art.
[0006] In order to achieve the above purpose, according to one aspect of the present application, a database abnormal condition detection method is provided. The method comprises: determining a target parameter table in a to-be-detected database according to the to-be-detected database; determining a target code corresponding to the target parameter table, and detecting preset statement change information corresponding to the target parameter table according to the target code, wherein the preset statement change information is used to represent the data operation change of the target parameter table; and triggering an abnormal condition prompt of the to-be-detected database according to the preset statement change information.
[0007] Further, determining a target parameter table in a to-be-detected database according to the to-be-detected database comprises: obtaining all field names involved in the data tables in the to-be-detected database, and obtaining the occurrence frequency of each field name in the to-be-detected database; obtaining the update frequency of each data table; and determining the target parameter table according to the occurrence frequency of the field name and the update frequency of the data table.
[0008] Further, the determining the target code corresponding to the target parameter table comprises: receiving a code configuration file, wherein the code configuration file comprises a plurality of preset table names and preset codes corresponding to each preset table name; and determining the target code according to the code configuration file.
[0009] Further, the detecting the preset statement change information corresponding to the target parameter table according to the target code comprises: defining an interception method in a preset code interceptor; filling an interception parameter in the interception method according to the target code, wherein the target code comprises at least one of a data insertion operation code, a data update operation code and a data deletion operation code; and intercepting an execution statement of the target parameter table according to the interception method after the interception parameter is filled, to obtain the preset statement change information corresponding to the target parameter table.
[0010] Further, the triggering the abnormal condition prompt of the to-be-detected database according to the preset statement change information comprises: updating a change number and a timestamp recording a statement change situation in a preset cache database whenever the preset statement change information is detected in the to-be-detected database; and triggering the abnormal condition prompt according to the change number and the timestamp.
[0011] Further, the triggering the abnormal condition prompt according to the change number and the timestamp comprises: acquiring the change number in a preset time interval according to the timestamp every preset time interval; and triggering the abnormal condition prompt and resetting the change number in the preset cache database if the change number in the preset time interval is greater than a preset number threshold.
[0012] To achieve the above object, according to another aspect of the present application, a database abnormal condition detection device is provided. The device comprises: a parameter table determination unit configured to determine a target parameter table in a to-be-detected database according to the to-be-detected database; a preset information extraction unit configured to determine a target code corresponding to the target parameter table, and detect preset statement change information corresponding to the target parameter table according to the target code, wherein the preset statement change information is used to represent a data operation change situation of the target parameter table; and an abnormal condition triggering unit configured to trigger an abnormal condition prompt of the to-be-detected database according to the preset statement change information.
[0013] Further, the parameter table determination unit comprises: a first frequency module configured to acquire all field names involved in a data table in the to-be-detected database, and acquire an occurrence frequency of each field name in the to-be-detected database; a second frequency module configured to acquire an update frequency of each data table; and a determination module configured to determine the target parameter table according to the occurrence frequency of the field name and the update frequency of the data table.
[0014] Further, the preset information extraction unit comprises: a code configuration module, configured to receive a code configuration file, wherein the code configuration file comprises a plurality of preset table names and preset codes corresponding to each preset table name; and a code determination module, configured to determine a target code according to the code configuration file.
[0015] Further, the preset information extraction unit further comprises: an interception definition module, configured to define an interception method in the preset code interceptor; a parameter filling module, configured to fill an interception parameter in the interception method according to the target code, wherein the target code comprises at least one of a data insertion operation code, a data update operation code and a data deletion operation code; and a statement interception module, configured to intercept an execution statement of the target parameter table according to the interception method with the filled interception parameter, to obtain preset statement change information corresponding to the target parameter table.
[0016] Further, the abnormal condition triggering unit comprises: a timestamp recording module, configured to update a change number and a timestamp of a statement change in the preset cache database whenever the preset statement change information is detected in the to-be-detected database; and a triggering prompt module, configured to trigger an abnormal condition prompt according to the change number and the timestamp.
[0017] Further, the triggering prompt module comprises: a change number monitoring submodule, configured to acquire the change number in a preset time interval according to the timestamp every preset time interval; and a triggering zeroing submodule, configured to trigger the abnormal condition prompt and zero the change number in the preset cache database if the change number in the preset time interval is greater than a preset number threshold.
[0018] According to another aspect of the present application, a computer readable storage medium is provided, which comprises a stored program, wherein the program, when executed, controls the device where the computer readable storage medium is located to perform any of the database abnormal condition detection methods.
[0019] According to another aspect of the present application, an electronic device is provided, which comprises one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs comprise a program for performing any of the database abnormal condition detection methods.
[0020] According to another aspect of the present application, a computer program product is provided, which comprises computer instructions, and the computer instructions, when executed by a processor, implement the steps of any of the database abnormal condition detection methods.
[0021] In the embodiment of the present application, the target parameter table in the to-be-detected database is determined according to the to-be-detected database; the target code corresponding to the target parameter table is determined, and the preset statement change information corresponding to the target parameter table is detected according to the target code, wherein the preset statement change information is used to represent the data operation change of the target parameter table; the abnormal condition prompt of the to-be-detected database is triggered according to the preset statement change information, which solves the technical problem of low detection efficiency of the database abnormal condition in the prior art.
[0022] By determining the target parameter table in the to-be-detected database, the change of the target parameter table can be selectively monitored, instead of indiscriminately monitoring all database operations, which significantly reduces the data processing amount of abnormal detection; at the same time, by using the association between the target code and the target parameter table, the data change related to specific business logic or operation can be more effectively tracked and detected, instead of simply monitoring all data updates. This method can quickly locate the possible abnormal operation source from the code level, reduce the troubleshooting time, and improve the response speed. In addition, by collecting the preset statement change information in real time at the database operation level and responding in time, there is no need to wait for periodic data audit or log analysis, which significantly improves the real-time performance of abnormal detection. Therefore, the technical scheme of the present application effectively improves the detection efficiency of the database abnormality. BRIEF DESCRIPTION OF DRAWINGS
[0023] The accompanying drawings, which form a part of the present application, are intended to provide further understanding of the present application, and the illustrative embodiments of the present application and their description serve the purpose of explaining the present application. The accompanying drawings should not be construed as an inappropriate limitation on the present application. In the drawings:
[0024] Figure 1 Fig. 1 shows a hardware structure block diagram of a computer terminal for implementing the detection method of the database abnormal condition;
[0025] Figure 2 Fig. 2 is a flow chart of the detection method of the database abnormal condition according to the embodiment of the present application;
[0026] Figure 3 Fig. 3 is a schematic diagram of the detection device of the database abnormal condition according to the embodiment of the present application;
[0027] Figure 4 Fig. 4 is a structure block diagram of an electronic device according to the embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to make the person skilled in the art better understand the scheme of the present application, the technical scheme in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor should be within the scope of protection of the present application.
[0029] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0030] First, some nouns or terms appearing in the description of the embodiments of the present application are applicable to the following explanations:
[0031] It should be noted that the information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for display, analyzed data, etc.) involved in the present application are information and data authorized by the user or authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of related data comply with relevant laws, regulations and standards, take necessary security measures, do not violate public order and good customs, and provide corresponding operation portal for user to choose authorization or refusal. For example, the system and the interface between the related users or institutions provide the corresponding operation portal for the user to choose to agree or refuse the automatic decision result; if the user chooses to refuse, the expert decision process is entered.
[0032] Embodiment 1
[0033] According to the embodiments of the present application, a method for detecting database abnormal conditions is also provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described herein can be executed in a different order from that shown herein.
[0034] The method provided in the embodiment one of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing the detection method of database abnormal conditions is shown. As shown in the figure, Figure 1 The computer terminal 10 (or mobile device) can include one or more processors 102 (the processor 102 can include but is not limited to a microprocessor MCU or a programmable logic device FPGA processing device), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it can also include a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. Those skilled in the art can understand that, Figure 1 The structure shown is only schematic, which does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 can include more or less components than those shown in the figure, or have a different configuration from that shown in the figure. Figure 1 The structure shown is only schematic, which does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 can include more or less components than those shown in the figure, or have a different configuration from that shown in the figure. Figure 1 The structure shown is only schematic, which does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 can include more or less components than those shown in the figure, or have a different configuration from that shown in the figure.
[0035] It should be noted that the one or more processors 102 and / or other data processing circuits described above can be referred to herein as "data processing circuits" in general. The data processing circuit can be embodied in whole or in part as software, hardware, firmware or any other combination. In addition, the data processing circuit can be a single independent processing module, or all or part of any one of the other elements combined into the computer terminal 10 (or mobile device). As referred to in the embodiments of the present application, the data processing circuit as a kind of processor control (for example, the selection of variable resistance terminal path connected with the interface).
[0036] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device of the detection method of database abnormal conditions in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the detection method of database abnormal conditions described above. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, which can be connected to the computer terminal 10 through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0037] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of the computer terminal 10. In an example, the transmission device 106 includes a network interface controller (NIC) that can be connected to other network devices through a base station to communicate with the Internet. In an example, the transmission device 106 can be a radio frequency (RF) module that is configured to communicate with the Internet in a wireless manner.
[0038] The display can be a liquid crystal display (LCD) that is touch screen type, for example, which can enable a user to interact with a user interface of the computer terminal 10 (or a mobile device).
[0039] In the above operating environment, the present application provides a method for detecting database abnormal conditions as shown in Figure 2 Figure 2 is a flowchart of the method for detecting database abnormal conditions according to an embodiment of the present application.
[0040] In step S201, a target parameter table in the database to be detected is determined according to the database to be detected.
[0041] Optionally, the target parameter table is a specific table in the database to be detected that stores system configuration information and business rules, i.e., a database configuration table. The target parameter table usually includes a series of predefined and configurable parameters.
[0042] For example, in the database of a target financial institution, the target parameter table refers to a table that stores configuration data such as account types, transaction limits, and holiday lists. The data in the target parameter table is the focus of attention in database monitoring, maintenance, and management activities. Compared with general tables, the data in the target parameter table needs to be changed more carefully because changes in the target parameter table can affect the functions or performance of the entire system.
[0043] Optionally, the determination of the target parameter table in the database to be detected can be implemented based on a predefined list. For example, a list containing all target parameter tables to be monitored is created in advance. This list can be stored in a configuration file in XML or JSON format or in another database table as a reference. When the system is started, the list is read, and the contents of the target parameter tables in the list are loaded into the memory for subsequent detection.
[0044] In step S202, a target code corresponding to the target parameter table is determined, and preset statement change information corresponding to the target parameter table is detected according to the target code. The preset statement change information is used to represent the data operation change of the target parameter table.
[0045] Optionally, a comment or configuration mapping can be added to each access or modification of the structure of the target parameter table, and the structure operation is marked as a specific target code. The target code can be a custom annotation, a configuration item or a function name. By detecting the changes of the target code, the preset statement change information of the target parameter table can be quickly determined. The preset statement change information is used to represent the data operation change of the target parameter table, that is, the preset statement change information refers to the information generated when the data operation of the target parameter table in the to-be-detected database is modified. Such information reflects the structure change of the target parameter table. It should be noted that the operation statement of the database includes a DDL statement (Data Definition Language) and a DML statement (Data Manipulation Language), and the preset statement change information is only related to the DML statement.
[0046] For example, the target parameter table is a table named "cbps_cnapscasaccountlog". When it is detected that the target code has a data insertion operation, it is determined that the preset statement change information of the target parameter table is detected.
[0047] In step S203, the abnormal condition prompt of the to-be-detected database is triggered according to the preset statement change information.
[0048] Optionally, when the frequency of occurrence of the preset statement change information within a preset time period is greater than a preset threshold, it can be determined that the abnormal state prompt of the to-be-detected database is triggered. The alarm mechanism of multiple levels can be set for the abnormal state prompt according to the numerical value of the frequency of occurrence.
[0049] For example, the data insertion operation of the target parameter table occurs 5 times within 1 hour, that is, the preset statement change information occurs 5 times, and the preset threshold is 3 times. When the abnormal state prompt is triggered, the abnormal state prompt can include detailed information such as the table name of the target parameter table, the operation type, the number of operations per unit time, etc.
[0050] In summary, by determining the target parameter table in the to-be-detected database, the change of the target parameter table can be selectively monitored instead of indiscriminately monitoring all database operations, thereby significantly reducing the data processing amount of anomaly detection; meanwhile, by using the association between the target code and the target parameter table, the data change related to a specific business logic or operation can be more effectively tracked and detected instead of simply monitoring all data updates, which can quickly locate the possible abnormal operation source from the code level, reduce the troubleshooting time, and improve the response speed; in addition, by collecting the preset statement change information in real time at the database operation level and responding in a timely manner, the periodic data audit or log analysis is not needed, thereby significantly improving the real-time performance of anomaly detection. Therefore, the technical scheme of the present application effectively improves the detection efficiency of database anomalies.
[0051] To improve the detection efficiency of database anomalies, optionally, determining the target parameter table in the to-be-detected database includes: obtaining all field names involved in the data tables in the to-be-detected database, and obtaining the occurrence frequency of each field name in the to-be-detected database; obtaining the update frequency of each data table; and determining the target parameter table according to the occurrence frequency of the field name and the update frequency of the data table.
[0052] Optionally, the occurrence frequency of each field in the to-be-detected database can be counted, and the fields with high occurrence frequency often indicate that they have strong importance in the business logic; the update frequency of each data table in the to-be-detected database in a preset period can also be counted, and the table with low update frequency has strong stability. The number of target parameter tables can be one, two, or three.
[0053] For example, the occurrence frequency of each field in all data tables in the to-be-detected database can be obtained first, then the average occurrence frequency of the fields of each data table is determined according to the occurrence frequency, ten data tables with the top ten average occurrence frequencies of the fields are obtained, and the data table with the lowest update frequency in the ten data tables is taken as the target parameter table.
[0054] In summary, by taking the occurrence frequency of the field as the importance indicator and the update frequency of the data table as the stability indicator, the target parameter table is determined, and the target parameter table is taken as the target of detecting database anomalies, thereby avoiding scanning the entire database and improving the detection efficiency of database anomalies.
[0055] To improve the flexibility of detecting database anomalies, optionally, determining the target code corresponding to the target parameter table includes: receiving a code configuration file, wherein the code configuration file includes a plurality of preset table names and a preset code corresponding to each preset table name; and determining the target code according to the code configuration file.
[0056] Optionally, a pre-configured code configuration file can be read to obtain all preset preset table names and their corresponding preset codes. The preset codes can be codes related to anomaly detection. The code configuration file can be updated at a fixed period to adapt to business changes or database anomaly detection requirements.
[0057] For example, the code configuration file can be a file named "Config.json", which can include multiple preset table names. For the data table with the preset table name "cbps_cnapscasaccountlog", its corresponding preset codes are "insert" and "update". In addition, the preset code can also include "delete". The code configuration file can also include other preset table names and their corresponding preset codes. The corresponding preset codes of different preset table names can be the same or different. When the target parameter table changes, the corresponding target code of the changed target parameter table can be determined according to the code configuration file.
[0058] In summary, through the code configuration file, specific preset codes can be flexibly set for different data tables, so that for any target parameter table, the target code can be quickly determined according to the code configuration file. This flexibility enables the method of the embodiment to quickly adjust the target parameter table corresponding to anomaly detection as the business develops and requirements change, effectively improving the flexibility of detecting database anomaly conditions.
[0059] In order to improve the detection efficiency of the database anomaly condition, optionally, the preset statement change information corresponding to the target parameter table according to the target code includes: defining an interception method in the preset code interceptor; filling the interception parameters in the interception method according to the target code, wherein the target code includes at least one of a data insertion operation code, a data update operation code, and a data deletion operation code; and intercepting the execution statement of the target parameter table according to the interception method after filling the interception parameters to obtain the preset statement change information corresponding to the target parameter table.
[0060] Optionally, the preset code interceptor allows inserting custom logic before and after the execution of the database statement, thereby enhancing or modifying the framework without modifying the original code. Meanwhile, the preset code interceptor, based on the aspect-oriented programming idea, can add additional processing steps to the execution path of the database statement by implementing a specific interface and configuring it into the framework. A preset code interceptor can be defined in the code library of the database to be detected, and the preset code interceptor is used to intercept specific database statement types, such as data insertion operation code, data update operation code, and data deletion operation code. The interception method can be defined in the preset code interceptor, and the interception parameters of the interception method can be filled according to the target code. The interception parameters are used to identify and distinguish different types of database operations, that is, by filling the interception parameters based on the target code, the dynamic filling of the interception parameters is realized, ensuring that the preset code interceptor can correctly identify and intercept the preset statement change information.
[0061] For example, a class named "DataBaseOperationMonitorConfig" can be created, and the class is used to read the information in the code configuration file "Config.json" to determine the target code. The preset interceptor can be mybatis (an open source persistence layer framework). The interception method can be defined in the preset interceptor, and the interception parameters "insert", "update", and "delete" can be filled in the interception method to intercept and obtain the preset statement change information.
[0062] In summary, by defining the interception method in the preset code interceptor and filling the interception parameters, the quick and automated interception of the preset statement change information from the code level is realized, and the efficiency of database anomaly detection is improved.
[0063] In order to improve the detection efficiency of the database abnormal condition, optionally, triggering the abnormal condition prompt of the database to be detected according to the preset statement change information includes: updating the number of changes and the time stamp of the statement change record in the preset cache database every time the preset statement change information of the database to be detected is detected; triggering the abnormal condition prompt according to the number of changes and the time stamp.
[0064] Optionally, a preset cache database can be constructed to store the preset statement change information corresponding to the database to be detected. The cache database can efficiently store and update data, and has high-speed read and write capability, thereby ensuring the detection efficiency of the database abnormal condition. Every time the preset statement change information is detected, the number of changes is updated in the preset cache database, and the time stamp of each update is recorded. The number of changes can reflect the frequency of the occurrence of the preset statement change information, and the time stamp is used to track the time of each change. The abnormal condition prompt can be triggered when the number of changes exceeds a preset number threshold.
[0065] In summary, by constructing the cache-based exception detection and prompting mechanism, the real-time performance of the database exception condition detection is improved, thereby improving the detection efficiency of the database exception condition.
[0066] To improve the detection efficiency of the database exception condition, optionally, the triggering of the exception condition prompt according to the number of changes and the time stamp comprises: acquiring the number of changes in a preset time interval according to the time stamp every preset time interval; if the number of changes in the preset time interval is greater than a preset number threshold, triggering the exception condition prompt, and resetting the number of changes in the preset cache database to zero.
[0067] For example, a counter can be set in the preset cache database to count the number of changes, and the preset statement change information occurring after a first time is recorded, and the number of the counter is increased by 1 every time the preset statement change information is detected. The preset time interval can be 1 hour, and the second time can be determined according to the current time stamp of the system where the database to be detected is located, the time difference is obtained by subtracting the first time from the second time, if the time difference is greater than 1 hour (i.e., the preset time interval), the number of the counter (representing the number of changes) at this time is acquired, if the number of the counter is 5 and the preset number threshold is 3, the exception condition prompt is triggered, and the number of the counter is reset to zero; if the number of the counter is 2, the exception condition prompt is not triggered, and the number of the counter is directly reset to zero.
[0068] In summary, by adopting the detection strategy combining the number of changes and the time stamp, and setting the timing reset mechanism, the repeated prompt of a single exception event is avoided, and the efficiency of the database exception condition detection is improved.
[0069] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a group of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0070] Embodiment 2
[0071] The embodiment of the present application also provides a database exception condition detection device. It should be noted that the database exception condition detection device of the embodiment of the present application can be used to execute the database exception condition detection method provided by the embodiment of the present application. The database exception condition detection device provided by the embodiment of the present application is introduced as follows.
[0072] According to the embodiment of the present application, a device for implementing the above-mentioned database exception condition detection method is also provided, as shown in Figure 3 The device comprises:
[0073] The parameter table determination unit 301 is configured to determine a target parameter table in the to-be-detected database according to the to-be-detected database.
[0074] The preset information extraction unit 302 is configured to determine a target code corresponding to the target parameter table, and detect preset statement change information corresponding to the target parameter table according to the target code, where the preset statement change information is used to represent a data operation change situation of the target parameter table.
[0075] The abnormal condition triggering unit 303 is configured to trigger an abnormal condition prompt of the to-be-detected database according to the preset statement change information.
[0076] The database abnormal condition detection device provided in the embodiment of the present application determines a target parameter table in the to-be-detected database according to the to-be-detected database through the parameter table determination unit 301, determines a target code corresponding to the target parameter table, and detects preset statement change information corresponding to the target parameter table according to the target code through the preset information extraction unit 302, where the preset statement change information is used to represent a data operation change situation of the target parameter table, and an abnormal condition prompt of the to-be-detected database is triggered according to the preset statement change information through the abnormal condition triggering unit 303, thereby solving the problem of low detection efficiency of the database abnormal condition in the related art, and achieving the effect of improving the detection efficiency of the database abnormal condition.
[0077] Optionally, in the database abnormal condition detection device provided in the embodiment of the present application, the parameter table determination unit 301 includes: a first frequency module configured to acquire all field names involved in a data table in the to-be-detected database, and acquire an occurrence frequency of each field name in the to-be-detected database; a second frequency module configured to acquire an update frequency of each data table; and a determination module configured to determine the target parameter table according to the occurrence frequency of the field name and the update frequency of the data table.
[0078] Optionally, in the database abnormal condition detection device provided in the embodiment of the present application, the preset information extraction unit 302 includes: a code configuration module configured to receive a code configuration file, where the code configuration file includes a plurality of preset table names and preset codes corresponding to each preset table name; and a code determination module configured to determine the target code according to the code configuration file.
[0079] Optionally, in the database anomaly detection device provided in this application embodiment, the preset information extraction unit 302 further includes: an interception definition module, used to define an interception method in a preset code interceptor; a parameter filling module, used to fill the interception parameters in the interception method according to the target code, wherein the target code includes at least one of data insertion operation code, data update operation code, and data deletion operation code; and a statement interception module, used to intercept the execution statement of the target parameter table according to the interception method after filling the interception parameters, and obtain the preset statement change information corresponding to the target parameter table.
[0080] Optionally, in the database anomaly detection device provided in this application embodiment, the anomaly triggering unit 303 includes: a timestamp recording module, used to update the number of changes and the timestamp recording the statement change information in a preset cache database whenever preset statement change information is detected in the database to be detected; and a trigger prompting module, used to trigger an anomaly prompt based on the number of changes and the timestamp.
[0081] Optionally, in the database anomaly detection device provided in this application embodiment, the trigger prompt module includes: a frequency change monitoring submodule, used to obtain the number of changes within the preset time interval based on the timestamp at every preset time interval; and a trigger clearing submodule, used to trigger an anomaly prompt and reset the number of changes in the preset cache database to zero if the number of changes within the preset time interval is greater than a preset frequency threshold.
[0082] It should be noted that the parameter table determination unit 301, the preset information extraction unit 302, and the abnormal situation triggering unit 303 mentioned above correspond to steps S201 to S204 in Embodiment 1. The instances and application scenarios implemented by the units and corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above modules can also be part of the device and run in the computer terminal 10 provided in Embodiment 1.
[0083] Example 3
[0084] Embodiments of this application may provide an electronic device. Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 4 As shown, the electronic device may include: one or more ( Figure 4 (Only one is shown) processor 1002, memory 1004, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0085] The memory can be used to store software programs and modules, such as program instructions / modules corresponding to the method and device in the embodiments of the present application. The processor executes various functions and data processing by running the software programs and modules stored in the memory, that is, implements the above method. The memory can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory can further include a memory remotely arranged with respect to the processor, which can be connected to the terminal through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0086] The processor can call information and application programs stored in the memory through the transmission device to perform the following steps: determining a target parameter table in the to-be-detected database according to the to-be-detected database; determining a target code corresponding to the target parameter table, and detecting preset statement change information corresponding to the target parameter table according to the target code, wherein the preset statement change information is used to represent a data operation change of the target parameter table; triggering an abnormal condition prompt of the to-be-detected database according to the preset statement change information.
[0087] The processor can further call information and application programs stored in the memory through the transmission device to perform the following steps: obtaining all field names involved in the data tables in the to-be-detected database, and obtaining the occurrence frequency of each field name in the to-be-detected database; obtaining the update frequency of each data table; determining the target parameter table according to the occurrence frequency of the field name and the update frequency of the data table.
[0088] The processor can further call information and application programs stored in the memory through the transmission device to perform the following steps: receiving a code configuration file, wherein the code configuration file includes a plurality of preset table names and a preset code corresponding to each preset table name; determining the target code according to the code configuration file.
[0089] The processor can further call information and application programs stored in the memory through the transmission device to perform the following steps: defining an interception method in the preset code interceptor; filling an interception parameter in the interception method according to the target code, wherein the target code includes at least one of a data insertion operation code, a data update operation code, and a data deletion operation code; intercepting an execution statement of the target parameter table according to the interception method after filling the interception parameter, to obtain the preset statement change information corresponding to the target parameter table.
[0090] The processor can also call information and application programs stored in the memory through the transmission device to perform the following steps: whenever detecting that the preset statement change information appears in the database to be detected, updating the change times and the time stamp recording the statement change in the preset cache database; triggering the abnormal condition prompt according to the change times and the time stamp.
[0091] The processor can also call information and application programs stored in the memory through the transmission device to perform the following steps: every preset time interval, obtaining the change times in the preset time interval according to the time stamp; if the change times in the preset time interval are greater than a preset number threshold, triggering the abnormal condition prompt and resetting the change times in the preset cache database to zero.
[0092] By determining the target parameter table in the database to be detected according to the database to be detected, determining the target code corresponding to the target parameter table, and detecting the preset statement change information corresponding to the target parameter table according to the target code, wherein the preset statement change information is used to represent the data operation change of the target parameter table, and triggering the abnormal condition prompt of the database to be detected according to the preset statement change information, the technical problem of low detection efficiency of the database abnormal condition in the prior art is solved.
[0093] Those skilled in the art can understand that Figure 4 The structure shown is only schematic, and the electronic device can also be a terminal device such as a smart phone, a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, etc. Figure 4 It does not limit the structure of the electronic device. For example, the electronic device can further include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 4 For example, the electronic device can further include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 4 For example, the electronic device can further include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure.
[0094] Those skilled in the art can understand that all or part of the steps in the above embodiments can be completed by programs instructing the related hardware of the terminal device, and the programs can be stored in a computer readable storage medium, which can include a flash disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, etc.
[0095] Embodiment 4
[0096] The embodiment of the present application further provides a storage medium. Optionally, in the embodiment, the storage medium can be used to save the program code executed by the database abnormal condition detection method provided in the first embodiment.
[0097] Optionally, in the embodiment, the storage medium can be located in any computer terminal in the computer terminal group in the computer network, or in any mobile terminal in the mobile terminal group.
[0098] Optionally, in the embodiment, the computer readable storage medium is configured to store program code for performing the following steps: determining a target parameter table in the to-be-detected database according to the to-be-detected database; determining a target code corresponding to the target parameter table, and detecting preset statement change information corresponding to the target parameter table according to the target code, wherein the preset statement change information is used to represent the data operation change of the target parameter table; and triggering an abnormal condition prompt of the to-be-detected database according to the preset statement change information.
[0099] Optionally, in the embodiment, the computer readable storage medium is further configured to store program code for performing the following steps: obtaining all field names involved in the data tables in the to-be-detected database, and obtaining the occurrence frequency of each field name in the to-be-detected database; obtaining the update frequency of each data table; and determining the target parameter table according to the occurrence frequency of the field name and the update frequency of the data table.
[0100] Optionally, in the embodiment, the computer readable storage medium is further configured to store program code for performing the following steps: receiving a code configuration file, wherein the code configuration file includes a plurality of preset table names and preset codes corresponding to each preset table name; and determining the target code according to the code configuration file.
[0101] Optionally, in the embodiment, the computer readable storage medium is further configured to store program code for performing the following steps: defining an interception method in the preset code interceptor; filling an interception parameter in the interception method according to the target code, wherein the target code includes at least one of a data insertion operation code, a data update operation code and a data deletion operation code; and intercepting the execution statement of the target parameter table according to the interception method after filling the interception parameter, to obtain the preset statement change information corresponding to the target parameter table.
[0102] Optionally, in the embodiment, the computer readable storage medium is further configured to store program code for performing the following steps: updating the number of changes and the time stamp recording the statement change in the preset cache database whenever the preset statement change information is detected in the to-be-detected database; and triggering the abnormal condition prompt according to the number of changes and the time stamp.
[0103] Optionally, in the embodiment, the computer readable storage medium is further configured to store program code for performing the following steps: acquiring the number of changes in the preset time interval according to the time stamp every preset time interval; if the number of changes in the preset time interval is greater than a preset number threshold, triggering an abnormal condition prompt, and resetting the number of changes in the preset cache database.
[0104] The application further provides a computer program product, which is suitable for executing the steps of the database abnormal condition detection method when executed on a data processing device.
[0105] The above-mentioned serial numbers of the embodiments of the application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0106] In the above-mentioned embodiments of the application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0107] In the several embodiments provided by the present application, it should be understood that the disclosed technology can be implemented in other ways. Of course, the unit embodiment described above is only illustrative, and for example, the division of units is only a logical function division, and there can be another division manner in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, unit or module, and can be electrical or other forms.
[0108] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiment.
[0109] In addition, each functional unit in each embodiment of the application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0110] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or say the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0111] The above is only the preferred embodiment of the present application, and it should be pointed out that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should be considered as the protection scope of the present application.
Claims
1. A method for detecting database anomalies, characterized in that, include: The target parameter table in the database to be tested is determined based on the database to be tested; The target code corresponding to the target parameter table is determined, and the preset statement change information corresponding to the target parameter table is detected based on the target code, wherein the preset statement change information is used to characterize the data operation change of the target parameter table; The abnormal status prompt of the database to be tested is triggered based on the preset statement change information.
2. The method according to claim 1, characterized in that, The target parameter table in the database to be tested, determined based on the database to be tested, includes: Obtain all field names involved in the data tables of the database to be tested, and obtain the frequency of occurrence of each field name in the database to be tested; Obtain the update frequency of each of the data tables; The target parameter table is determined based on the frequency of occurrence of the field names and the update frequency of the data table.
3. The method according to claim 1, characterized in that, Determining the target code corresponding to the target parameter table includes: Receive a code configuration file, wherein the code configuration file includes multiple preset table names and preset codes corresponding to each preset table name; The target code is determined based on the code configuration file.
4. The method according to claim 1, characterized in that, The detection of preset statement change information corresponding to the target parameter table based on the target code includes: Define the interception method in the preset code interceptor; The interception parameters in the interception method are filled in according to the target code, wherein the target code includes at least one of data insertion operation code, data update operation code, and data deletion operation code; The execution statements of the target parameter table are intercepted according to the interception method after filling in the interception parameters, and the preset statement change information corresponding to the target parameter table is obtained.
5. The method according to claim 1, characterized in that, The abnormal status prompts triggered by the preset statement change information in the database to be tested include: Whenever the preset statement change information is detected in the database to be detected, the number of changes and the timestamp recording the statement change are updated in the preset cache database. The abnormal situation alert is triggered based on the number of changes and the timestamp.
6. The method according to claim 5, characterized in that, The abnormal situation alert is triggered based on the number of changes and the timestamp, including: At preset time intervals, the number of changes within the preset time interval is obtained based on the timestamp; If the number of changes within the preset time interval exceeds the preset number threshold, the abnormal situation prompt is triggered, and the number of changes in the preset cache database is reset to zero.
7. A device for detecting database anomalies, characterized in that, include: The parameter table determination unit is used to determine the target parameter table in the database to be detected based on the database to be detected. A preset information extraction unit is used to determine the target code corresponding to the target parameter table, and to detect the preset statement change information corresponding to the target parameter table based on the target code, wherein the preset statement change information is used to characterize the data operation change of the target parameter table; An abnormal situation triggering unit is used to trigger an abnormal situation prompt in the database to be detected based on the preset statement change information.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium is located to perform the database anomaly detection method according to any one of claims 1 to 7.
9. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, executes the database anomaly detection method according to any one of claims 1 to 7.
10. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the database anomaly detection method according to any one of claims 1 to 7.