Data change recording method and device of data table, storage medium and equipment

By generating operation log tables and status log tables and inserting change records in them using triggers, the problem of storing data change records in the prior art requires code development and cannot be recorded in all aspects, and efficient and comprehensive data change records are achieved .

CN119441234APending Publication Date: 2025-02-14TIANJUDIHE (SUZHOU) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411206268.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

When storing data change records in data tables, code development is required, which increases development costs, and different systems require multiple storage, so data changes cannot be recorded in all aspects.

Method used

By using the log table generator to generate the operation log table and the status log table, and using the trigger generator to generate the corresponding trigger according to the change type, insert the change record in the operation log table and the status log table.

Benefits of technology

No code development is required, which saves development costs. At the database level, you only need to store change records once, which can record changes in all fields in the data table in all aspects, improving the comprehensiveness of records.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441234A_ABST
    Figure CN119441234A_ABST
Patent Text Reader

Abstract

The invention discloses a data change recording method and device of a data table, a storage medium and equipment, and belongs to the technical field of computers. A data table is selected through a log table generator, an operation log table and a state log table are generated according to the data table, the operation log table is used for recording the change type of the data table and data before and after change, the state log table is used for recording the change state of the data table, and the operation log table and the state log table are associated through the same UUID; when the data in the data table is changed, a trigger generator is used for generating a corresponding trigger according to the change type; when the change type is insertion data, inserting a change record in an operation log table and a state log table based on the insertion data by using a corresponding first trigger; and when the change type is the modified data, inserting a change record in the operation log table and the state log table based on the modified data by utilizing the corresponding second trigger. According to the invention, the development cost can be saved, and the recording comprehensiveness is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, storage medium and equipment for recording data changes in a data table. Background Art

[0002] In traditional software development, when the data in a data table needs to be changed, it is necessary to maintain a record of the data change in each field in the data table and store the data change record in a log table.

[0003] In order to store data change records in the log table, it is necessary to write code for the stored procedure, and writing code involves code development, which increases development costs. In addition, each system needs to store data change records for each data table, and different systems need to implement multiple storages. In addition, the workload of storing data change records is large, and we usually only focus on the key fields in the data table and cannot record data changes in an all-round way. Summary of the invention

[0004] The present application provides a data table data change recording method, device, storage medium and equipment, which are used to solve the problem that code development is required for storing data changes, and different systems need to implement multiple storages, and data changes cannot be recorded in all directions. The technical solution is as follows:

[0005] According to a first aspect of the present application, a method for recording data changes in a data table is provided, the method comprising:

[0006] A data table is selected by using a log table generator, and an operation log table and a status log table are generated according to the data table, wherein the operation log table is used to record the change type of the data table and the data before and after the change, and the status log table is used to record the change status of the data table, and the operation log table and the status log table are associated by the same universal unique identifier UUID;

[0007] When the data in the data table is changed, a trigger generator is used to generate a corresponding trigger according to the change type;

[0008] When the change type is inserting data, inserting a change record in the operation log table and the status log table based on the inserting data using a corresponding first trigger;

[0009] When the change type is to modify data, a corresponding second trigger is used to insert a change record into the operation log table and the status log table based on the modified data.

[0010] In a possible implementation, inserting the change record in the operation log table and the status log table based on the insert data by using the corresponding first trigger includes:

[0011] Generate a UUID using the first trigger;

[0012] Utilize the first trigger to insert a first change record in the operation log table, set the auto-increment flag of the first change record, set the value of the UUID field in the first change record to the generated UUID, set the value of the operation type field in the first change record to a first value, set the value of the history type field in the first change record to a second value, fill the insert data into the corresponding field in the first change record, the first value indicates that the operation type is insert, and the second value indicates that the history type is the current value;

[0013] Use the first trigger to insert a second change record in the status log table, set the value of the UUID field in the second change record to the generated UUID, compare the inserted data with the value of the original data in the data table according to the field, and fill the comparison result into the corresponding field in the second change record, the comparison result includes a third value and a fourth value, the third value indicates that the value of the field has not changed, and the fourth value indicates the value of the newly added field.

[0014] In a possible implementation, inserting a change record into the operation log table and the status log table based on the modification data by using the corresponding second trigger includes:

[0015] Generate a UUID using the second trigger;

[0016] Utilize the second trigger to insert a third change record and a fourth change record in the operation log table, set the self-increment flags of the third change record and the fourth change record, set the value of the UUID field in the third change record and the fourth change record to the generated UUID, set the value of the operation type field in the third change record and the fourth change record to a fifth value, set the value of the history type field in the third change record to a sixth value, fill the original data corresponding to the inserted data into the corresponding field in the third change record, set the value of the history type field in the fourth change record to a second value, fill the inserted data into the corresponding field in the third change record, the fifth value indicates that the operation type is modification, the sixth value indicates that the history type is the last value, and the second value indicates that the history type is the current value;

[0017] The second trigger is used to insert the fifth change record in the status log table, the value of the UUID field in the fifth change record is set to the generated UUID, the inserted data is compared with the value of the original data in the data table according to the field, and the comparison result is filled into the corresponding field in the second change record, the comparison result includes a third value, a fourth value, a seventh value and an eighth value, the third value indicates that the value of the field has not changed, the fourth value indicates that the value of the field is newly added, the seventh value indicates that the value of the field is modified, and the eighth value indicates that the value of the field is deleted.

[0018] In a possible implementation, the method further includes:

[0019] Obtain a query request for the data table, wherein the query request carries a UUID;

[0020] Searching the change record corresponding to the UUID in the log operation table and the log status table;

[0021] Generate a change result according to the change record, wherein the change result includes a change type, a change field, and a value of the change field;

[0022] The change result is displayed.

[0023] In a possible implementation, generating a change result according to the change record includes:

[0024] When the change record includes a third change record, a fourth change record and a fifth change record, determining a field in the fifth change record whose value is the fourth value, the seventh value or the eighth value as a changed field;

[0025] Setting the change type of the change field of the fourth value to new addition, identifying the fourth change record according to the self-increment identifier, obtaining the current value of the change field in the fourth change record, and obtaining a change result;

[0026] The change type of the change field of the seventh value is set to modification, the third change record and the fourth change record are identified according to the self-increment identifier, the last value of the change field is obtained in the third change record, and the current value of the change field is obtained in the fourth change record to obtain the change result;

[0027] The change type of the change field of the eighth value is set to deletion, the third change record is identified according to the self-increment identifier, the last value of the change field is obtained in the third change record, and the change result is obtained.

[0028] In a possible implementation, generating a change result according to the change record includes:

[0029] When the change record includes a first change record and a second change record, determining a field in the second change record whose value is a fourth value as a changed field;

[0030] The change type of the changed field is set to new addition, and the current value of the changed field is obtained in the first change record to obtain the change result.

[0031] In a possible implementation, the displaying of the change result includes:

[0032] When the change type is new addition, the current value in the change result is displayed with the first background color;

[0033] When the change type is modification, the current value in the change result is displayed with a first background color, the last value in the change result is displayed with a second background color, and a strikethrough mark is set for the last value;

[0034] When the change type is deletion, the last value in the change result is displayed with a second background color, and a deletion line mark is set for the last value.

[0035] According to a second aspect of the present application, a data table data change recording device is provided, the device comprising:

[0036] A selection module, used to select a data table using a log table generator, and generate an operation log table and a status log table according to the data table, wherein the operation log table is used to record the change type of the data table and the data before and after the change, and the status log table is used to record the change status of the data table, and the operation log table and the status log table are associated through the same universal unique identifier UUID;

[0037] A generating module, used for generating corresponding triggers according to the change type by using a trigger generator when the data in the data table is changed;

[0038] A recording module, configured to insert a change record in the operation log table and the status log table based on the inserted data by using a corresponding first trigger when the change type is inserting data;

[0039] The recording module is further configured to, when the change type is data modification, insert a change record into the operation log table and the status log table based on the modification data using a corresponding second trigger.

[0040] According to a third aspect of the present application, a computer-readable storage medium is provided, wherein at least one instruction is stored in the storage medium, and the at least one instruction is loaded and executed by a processor to implement the data change recording method of the data table as described above.

[0041] According to a fourth aspect of the present application, a computer device is provided, the computer device comprising the data change recording device of the above-mentioned data table.

[0042] The beneficial effects of the technical solution provided by this application include at least:

[0043] Use the log table generator to generate the operation log table and status log table. When the data in the data table is changed, use the trigger generator to generate the corresponding trigger, and insert the change record in the operation log table or status log table through the trigger. In this way, the change record can be generated by the trigger at the database level, without the need for code development, thus saving development costs; the change record only needs to be stored once at the database level, without the need for repeated storage; and change records can be made for all fields in the data table, which can record data changes in all aspects and improve the comprehensiveness of the record. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0045] Figure 1 is a flow chart of a method for recording data changes in a data table provided by an embodiment of the present application;

[0046] Figure 2 is a flow chart of a method for recording data changes in a data table provided by an embodiment of the present application;

[0047] Figure 3 is a schematic diagram of a change record provided by an embodiment of the present application;

[0048] Figure 4 It is a structural block diagram of a data change recording device for a data table provided by an embodiment of the present application. DETAILED DESCRIPTION

[0049] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0050] like Figure 1As shown, it shows a method flow chart of a data table data change recording method provided by an embodiment of the present application, and the data table data change recording method can be applied to a computer device. The data table data change recording method may include:

[0051] Step 101, use the log table generator to select a data table, and generate an operation log table and a status log table based on the data table. The operation log table is used to record the change type of the data table and the data before and after the change. The status log table is used to record the change status of the data table, and the operation log table and the status log table are associated through the same UUID.

[0052] A data table can be any table in a database, containing fields and values. For example, if the data table is a user table (user), the user table includes the following fields: user_id (user number), user_name (user name), name (name), age (age), birthday (birthday), sex (sex), creator (creator), updater (modifier), etc.

[0053] In addition to all the fields and values ​​of the data table, the operation log table also includes at least four fields, namely: the auto-increment identification field (history_id), the Universally Unique Identifier (UUID) field (history_uuid), the operation type field (history_operator_type) and the history type field (history_type). Among them, the value of the auto-increment identification field is the auto-increment identification of the change record. The value of the UUID field is the UUID. The value of the operation type field is the first value or the fifth value, the first value indicates that the change type is to insert data, the fifth value indicates that the change type is to modify data, and the first value and the fifth value can be any values, for example, the first value is 0 and the fifth value is 1. The value of the history type field is the second value or the sixth value, the second value indicates that the current value, that is, the newly written data, is stored in this change record, and the sixth value indicates that the last value, that is, the original data, is stored in this change record, and the second value and the sixth value can be any values, for example, the second value is 1 and the sixth value is 0.

[0054] The status log table includes all the fields of the data table, and the value of each field is the comparison result before and after the data is changed, and its values ​​include the third value, the fourth value, the seventh value and the eighth value. Among them, the third value indicates that the data remains unchanged, the fourth value indicates the newly added data, the seventh value indicates the modified data, and the eighth value indicates the deleted data. In addition to the fields of the data table, the status log table also includes at least two fields, namely: the self-increment identification field (history_status_id) and the UUID field. Among them, the value of the self-increment identification field is the self-increment identification of the change record. The value of the UUID field is the UUID.

[0055] Among them, the UUID generated when the same data is changed is the same, and the operation log table and the status log table can be associated through the UUID.

[0056] Step 102: When data in a data table is changed, a trigger generator is used to generate a corresponding trigger according to the change type.

[0057] The data change types include inserting data and modifying data. In this embodiment, a first trigger is generated for inserting data, and a second trigger is generated for modifying data. Specifically, a trigger can be generated by setting a monitoring event and a trigger logic of the trigger.

[0058] Step 103: When the change type is inserting data, inserting a change record into the operation log table and the status log table based on the inserting data using the corresponding first trigger.

[0059] The first trigger may insert a change record in the operation log table and a change record in the status log table according to the inserted data. The specific change records are described below.

[0060] Step 104: When the change type is to modify data, a corresponding second trigger is used to insert a change record into the operation log table and the status log table based on the modified data.

[0061] The second trigger may insert two change records in the operation log table and one change record in the status log table according to the inserted data. The specific change records are described below.

[0062] To summarize, the data change recording method for a data table provided in an embodiment of the present application utilizes a log table generator to generate an operation log table and a status log table. When the data in the data table is changed, a trigger generator is utilized to generate a corresponding trigger, and the change record is inserted into the operation log table or the status log table through the trigger. In this way, the change record can be generated through the trigger at the database level without the need for code development, thereby saving development costs; the change record only needs to be stored once at the database level without the need for repeated storage; and change records can be made for all fields in the data table, so that data changes can be recorded in all directions, thereby improving the comprehensiveness of the record.

[0063] like Figure 2 As shown, it shows a flow chart of a data table data change recording method provided by an embodiment of the present application, and the data table data change recording method can be applied to a computer device. The data table data change recording method may include:

[0064] Step 201, use the log table generator to select a data table, and generate an operation log table and a status log table based on the data table. The operation log table is used to record the change type of the data table and the data before and after the change. The status log table is used to record the change status of the data table, and the operation log table and the status log table are associated through the same UUID.

[0065] Step 202: When data in a data table is changed, a trigger generator is used to generate a corresponding trigger according to the change type.

[0066] The implementation process of steps 201-202 is the same as the implementation process of steps 101-102, and will not be repeated here.

[0067] Step 203: When the change type is inserting data, inserting a change record into the operation log table and the status log table based on the inserting data using the corresponding first trigger.

[0068] Specifically, inserting a change record into the operation log table and the status log table based on the inserted data using the corresponding first trigger may include:

[0069] (1) Generate a UUID using the first trigger.

[0070] (2) Use the first trigger to insert the first change record in the operation log table, set the auto-increment flag of the first change record, set the value of the UUID field in the first change record to the generated UUID, set the value of the operation type field in the first change record to the first value, set the value of the history type field in the first change record to the second value, and fill the insert data into the corresponding field in the first change record, where the first value indicates that the operation type is insert and the second value indicates that the history type is the current value.

[0071] Assuming that the first value is 0 and the second value is 1, in the first change record, history_operator_type=0, history_uuid=UUID, and history_type=1.

[0072] (3) Use the first trigger to insert a second change record in the status log table, set the value of the UUID field in the second change record to the generated UUID, compare the inserted data with the value of the original data in the data table according to the field, and fill the comparison result into the corresponding field in the second change record. The comparison result includes a third value and a fourth value. The third value indicates that the value of the field has not changed, and the fourth value indicates the value of the newly added field.

[0073] Assuming that the third value is 0 and the fourth value is 1, in the second change record, history_uuid=UUID, the field with unchanged data=0, and the field with newly added data=1.

[0074] Step 204: When the change type is to modify data, a corresponding second trigger is used to insert a change record into the operation log table and the status log table based on the modified data.

[0075] Specifically, inserting a change record into the operation log table and the status log table based on the modified data using the corresponding second trigger may include:

[0076] (1) Generate a UUID using the second trigger.

[0077] The second trigger may generate a UUID that is the same as the UUID generated by the first trigger; or, the second trigger may directly obtain the UUID generated by the first trigger.

[0078] (2) Use the second trigger to insert the third change record and the fourth change record into the operation log table, set the auto-increment flags of the third change record and the fourth change record, set the value of the UUID field in the third change record and the fourth change record to the generated UUID, set the value of the operation type field in the third change record and the fourth change record to the fifth value, set the value of the history type field in the third change record to the sixth value, fill the original data corresponding to the inserted data into the corresponding field in the third change record, set the value of the history type field in the fourth change record to the second value, fill the inserted data into the corresponding field in the third change record, the fifth value indicates that the operation type is modification, the sixth value indicates that the history type is the last value, and the second value indicates that the history type is the current value.

[0079] Assuming that the fifth value is 1, the sixth value is 0, and the second value is 1, then in the third change record, history_operator_type=1, history_uuid=UUID, history_type=0, and the values ​​of other fields are equivalent to the old values ​​of this record in the data table; in the fourth change record, history_operator_type=1, history_uuid=UUID, history_type=1, and the values ​​of other fields are equivalent to the new values ​​of this record in the data table.

[0080] (3) Use the second trigger to insert the fifth change record into the status log table, set the value of the UUID field in the fifth change record to the generated UUID, compare the inserted data with the value of the original data in the data table according to the field, and fill the comparison result into the corresponding field in the second change record. The comparison result includes the third value, the fourth value, the seventh value and the eighth value. The third value indicates that the value of the field has not changed, the fourth value indicates that the value of the field is newly added, the seventh value indicates that the value of the field is modified, and the eighth value indicates that the value of the field is deleted.

[0081] Assuming that the third value is 0, the fourth value is 1, the seventh value is 2, and the eighth value is 3, in the fifth change record, history_uuid = UUID, the field with unchanged data = 0, the field with newly added data = 1, the field with modified data = 2, and the field with deleted data = 3.

[0082] Optionally, after the operation log table and the status log table are generated, the changes in the data table may be displayed according to the operation log table and the status log table, and steps 205-207 are executed at this time.

[0083] Step 205: Obtain a query request for the data table, the query request carrying the UUID; search for a change record corresponding to the UUID in the log operation table and the log status table.

[0084] Optionally, the query request may also carry an auto-increment identifier to identify the change record corresponding to the auto-increment identifier.

[0085] Optionally, if the user's viewing authority is set, the query request may also carry a user ID to identify whether the user corresponding to the user ID has the viewing authority. Specifically, a whitelist may be set for each field, and the user IDs of each user with viewing authority may be set in the whitelist.

[0086] Step 206: Generate a change result according to the change record, where the change result includes a change type, a change field, and a value of the change field.

[0087] Among them, the change types include addition, modification and deletion.

[0088] Specifically, the change result generated according to the change record may include:

[0089] (1) When the change record includes a third change record, a fourth change record, and a fifth change record, a field in the fifth change record whose value is the fourth value, the seventh value, or the eighth value is determined as a changed field.

[0090] The third change record and the fourth change record corresponding to the UUID are searched in the operation log table, and the fifth change record corresponding to the UUID is searched in the status log table.

[0091] (2) The change type of the change field of the fourth value is set to new addition, the fourth change record is identified according to the self-increment identifier, and the current value of the change field in the fourth change record is obtained to obtain the change result.

[0092] In the change result, the change type is new addition, the changed field is the field of the fourth value, and the value is the value of the changed field.

[0093] (3) Set the change type of the change field of the seventh value to modification, identify the third change record and the fourth change record according to the self-increment identifier, obtain the last value of the change field in the third change record, obtain the current value of the change field in the fourth change record, and obtain the change result.

[0094] In the change result, the change type is modification, the change field is the seventh numerical value field, and the numerical value includes the last value and current value of the change field.

[0095] (4) The change type of the change field of the eighth value is set to delete, the third change record is identified according to the self-increment identifier, the last value of the change field in the third change record is obtained, and the change result is obtained.

[0096] In the change result, the change type is deletion, the change field is the field of the eighth value, and the value is the last value of the change field.

[0097] Specifically, generating a change result based on the change record also includes: when the change record includes a first change record and a second change record, determining the field in the second change record whose value is a fourth value as a changed field; setting the change type of the changed field to new addition, obtaining the current value of the changed field in the first change record, and obtaining the change result.

[0098] In the change result, the change type is new addition, the changed field is the field of the fourth value, and the value is the value of the changed field.

[0099] Step 207: Display the change result.

[0100] There are many ways to display the change results, and this embodiment uses one of them as an example to illustrate.

[0101] like Figure 3 As shown, the change results are displayed, which may include:

[0102] (1) When the change type is new, the current value in the change result is displayed in the first background color.

[0103] For example, the change type is "added", the field is "Incoterm", and the value is "FOB" displayed with a green background.

[0104] (2) When the change type is modification, the current value in the change result is displayed with the first background color, the last value in the change result is displayed with the second background color, and a deletion line mark is set for the last value.

[0105] The first background color and the second background color are different to distinguish them.

[0106] For example, the change type is "edited", the field is "Incoterm", the values ​​include "FOB" displayed with a red background color and "DDP" displayed with a green background color, and "FOB" is marked with a strikethrough.

[0107] (3) When the change type is deletion, the last value in the change result is displayed with the second background color, and a deletion line mark is set for the last value.

[0108] For example, the change type is "deleted", the field is "Solarcycle Contact Name", the value is "Sunny" displayed with a red background color, and a strikethrough mark is set on "Sunny".

[0109] To summarize, the data change recording method for a data table provided in an embodiment of the present application utilizes a log table generator to generate an operation log table and a status log table. When the data in the data table is changed, a trigger generator is utilized to generate a corresponding trigger, and the change record is inserted into the operation log table or the status log table through the trigger. In this way, the change record can be generated through the trigger at the database level without the need for code development, thereby saving development costs; the change record only needs to be stored once at the database level without the need for repeated storage; and change records can be made for all fields in the data table, so that data changes can be recorded in all directions, thereby improving the comprehensiveness of the record.

[0110] like Figure 4 As shown, it shows a structural block diagram of a data table data change recording device provided by an embodiment of the present application, and the data table data change recording device can be applied to a computer device. The data table data change recording device may include:

[0111] A selection module 410 is used to select a data table using a log table generator, and generate an operation log table and a status log table according to the data table, wherein the operation log table is used to record the change type of the data table and the data before and after the change, and the status log table is used to record the change status of the data table, and the operation log table and the status log table are associated through the same UUID;

[0112] A generating module 420, for generating a corresponding trigger according to the change type by using a trigger generator when the data in the data table is changed;

[0113] A recording module 430, for inserting a change record in an operation log table and a status log table based on the inserted data by using a corresponding first trigger when the change type is inserting data;

[0114] The recording module 430 is further configured to insert a change record into the operation log table and the status log table based on the modified data by using the corresponding second trigger when the change type is to modify data.

[0115] In an optional embodiment, the recording module 430 is further configured to:

[0116] Generate a UUID using the first trigger;

[0117] Use the first trigger to insert the first change record in the operation log table, set the auto-increment flag of the first change record, set the value of the UUID field in the first change record to the generated UUID, set the value of the operation type field in the first change record to the first value, set the value of the history type field in the first change record to the second value, fill the insert data into the corresponding field in the first change record, the first value indicates that the operation type is insert, and the second value indicates that the history type is the current value;

[0118] Use the first trigger to insert a second change record in the status log table, set the value of the UUID field in the second change record to the generated UUID, compare the inserted data with the value of the original data in the data table according to the field, fill the comparison result into the corresponding field in the second change record, the comparison result includes a third value and a fourth value, the third value indicates that the value of the field has not changed, and the fourth value indicates the value of the newly added field.

[0119] In an optional embodiment, the recording module 430 is further configured to:

[0120] Generate a UUID using the second trigger;

[0121] Use the second trigger to insert the third change record and the fourth change record in the operation log table, set the self-increment flags of the third change record and the fourth change record, set the value of the UUID field in the third change record and the fourth change record to the generated UUID, set the value of the operation type field in the third change record and the fourth change record to the fifth value, set the value of the history type field in the third change record to the sixth value, fill the original data corresponding to the inserted data into the corresponding field in the third change record, set the value of the history type field in the fourth change record to the second value, fill the inserted data into the corresponding field in the third change record, the fifth value indicates that the operation type is modification, the sixth value indicates that the history type is the last value, and the second value indicates that the history type is the current value;

[0122] Use the second trigger to insert the fifth change record in the status log table, set the value of the UUID field in the fifth change record to the generated UUID, compare the inserted data with the value of the original data in the data table according to the field, and fill the comparison result into the corresponding field in the second change record. The comparison result includes the third value, the fourth value, the seventh value and the eighth value. The third value indicates that the value of the field has not changed, the fourth value indicates that the value of the field is newly added, the seventh value indicates that the value of the field is modified, and the eighth value indicates that the value of the field is deleted.

[0123] In an optional embodiment, the device further includes a query module 440, which is used to:

[0124] Get the query request for the data table, which carries the UUID;

[0125] Find the change record corresponding to the UUID in the log operation table and log status table;

[0126] Generate a change result according to the change record, the change result includes the change type, the change field and the value of the change field;

[0127] Display the results of the changes.

[0128] In an optional embodiment, the query module 440 is further configured to:

[0129] When the change record includes a third change record, a fourth change record, and a fifth change record, determining a field in the fifth change record whose value is the fourth value, the seventh value, or the eighth value as a changed field;

[0130] The change type of the change field of the fourth value is set to new addition, the fourth change record is identified according to the self-increment identifier, and the current value of the change field is obtained in the fourth change record to obtain the change result;

[0131] The change type of the change field of the seventh value is set to modification, the third change record and the fourth change record are identified according to the self-incrementing identifier, the last value of the change field is obtained in the third change record, and the current value of the change field is obtained in the fourth change record to obtain the change result;

[0132] The change type of the change field of the eighth value is set to delete, the third change record is identified according to the self-increment identifier, the last value of the change field is obtained in the third change record, and the change result is obtained.

[0133] In an optional embodiment, the query module 440 is further configured to:

[0134] When the change record includes a first change record and a second change record, determining a field in the second change record whose value is a fourth value as a changed field;

[0135] The change type of the changed field is set to new addition, and the current value of the changed field is obtained in the first change record to obtain the change result.

[0136] In an optional embodiment, the query module 440 is further configured to:

[0137] When the change type is new, the current value in the change result is displayed with the first background color;

[0138] When the change type is modification, the current value in the change result is displayed with the first background color, the last value in the change result is displayed with the second background color, and a strikethrough mark is set for the last value;

[0139] When the change type is deletion, the last value in the change result is displayed with the second background color, and a delete line mark is set for the last value.

[0140] To summarize, the data change recording device for the data table provided in the embodiment of the present application uses a log table generator to generate an operation log table and a status log table. When the data in the data table is changed, a trigger generator is used to generate a corresponding trigger, and the change record is inserted into the operation log table or the status log table through the trigger. In this way, the change record can be generated by the trigger at the database level, without the need for code development, thus saving development costs; the change record only needs to be stored once at the database level, without the need for repeated storage; and change records can be made for all fields in the data table, so that data changes can be recorded in all directions, thereby improving the comprehensiveness of the record.

[0141] An embodiment of the present application provides a computer-readable storage medium, wherein the storage medium stores at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the data change recording method of the data table as described above.

[0142] An embodiment of the present application provides a computer device, which includes a data change recording device for any of the above-mentioned data tables.

[0143] It should be noted that: the data table data change recording device provided in the above embodiment only uses the division of the above functional modules as an example when recording the data changes of the data table. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the data table data change recording device is divided into different functional modules to complete all or part of the functions described above. In addition, the data table data change recording device provided in the above embodiment and the data table data change recording method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0144] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0145] The above description is not intended to limit the embodiments of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.

Claims

1. A method for recording data changes in a data table, characterized in that: The method comprises: A data table is selected by using a log table generator, and an operation log table and a status log table are generated according to the data table, wherein the operation log table is used to record the change type of the data table and the data before and after the change, and the status log table is used to record the change status of the data table, and the operation log table and the status log table are associated by the same universal unique identifier UUID; When the data in the data table is changed, a trigger generator is used to generate a corresponding trigger according to the change type; When the change type is inserting data, inserting a change record in the operation log table and the status log table based on the inserting data using a corresponding first trigger; When the change type is to modify data, a corresponding second trigger is used to insert a change record into the operation log table and the status log table based on the modified data.

2. The data table data change recording method according to claim 1, characterized in that: The using the corresponding first trigger to insert the change record in the operation log table and the status log table based on the inserted data includes: Generate a UUID using the first trigger; Utilize the first trigger to insert a first change record in the operation log table, set the auto-increment flag of the first change record, set the value of the UUID field in the first change record to the generated UUID, set the value of the operation type field in the first change record to a first value, set the value of the history type field in the first change record to a second value, fill the insert data into the corresponding field in the first change record, the first value indicates that the operation type is insert, and the second value indicates that the history type is the current value; Use the first trigger to insert a second change record in the status log table, set the value of the UUID field in the second change record to the generated UUID, compare the inserted data with the value of the original data in the data table according to the field, and fill the comparison result into the corresponding field in the second change record, the comparison result includes a third value and a fourth value, the third value indicates that the value of the field has not changed, and the fourth value indicates the value of the newly added field.

3. The data table data change recording method according to claim 1, characterized in that: The using the corresponding second trigger to insert the change record in the operation log table and the status log table based on the modification data includes: Generate a UUID using the second trigger; Utilize the second trigger to insert a third change record and a fourth change record in the operation log table, set the self-increment flags of the third change record and the fourth change record, set the value of the UUID field in the third change record and the fourth change record to the generated UUID, set the value of the operation type field in the third change record and the fourth change record to a fifth value, set the value of the history type field in the third change record to a sixth value, fill the original data corresponding to the inserted data into the corresponding field in the third change record, set the value of the history type field in the fourth change record to a second value, fill the inserted data into the corresponding field in the third change record, the fifth value indicates that the operation type is modification, the sixth value indicates that the history type is the last value, and the second value indicates that the history type is the current value; The second trigger is used to insert the fifth change record in the status log table, the value of the UUID field in the fifth change record is set to the generated UUID, the inserted data is compared with the value of the original data in the data table according to the field, and the comparison result is filled into the corresponding field in the second change record, the comparison result includes a third value, a fourth value, a seventh value and an eighth value, the third value indicates that the value of the field has not changed, the fourth value indicates that the value of the field is newly added, the seventh value indicates that the value of the field is modified, and the eighth value indicates that the value of the field is deleted.

4. The method for recording data changes in a data table according to any one of claims 1 to 3, characterized in that: The method further comprises: Obtain a query request for the data table, wherein the query request carries a UUID; Searching the change record corresponding to the UUID in the log operation table and the log status table; Generate a change result according to the change record, wherein the change result includes a change type, a change field, and a value of the change field; The change result is displayed.

5. The data table data change recording method according to claim 4, characterized in that: Generating a change result according to the change record includes: When the change record includes a third change record, a fourth change record and a fifth change record, determining a field in the fifth change record whose value is the fourth value, the seventh value or the eighth value as a changed field; Setting the change type of the change field of the fourth value to new addition, identifying the fourth change record according to the self-increment identifier, obtaining the current value of the change field in the fourth change record, and obtaining a change result; The change type of the change field of the seventh value is set to modification, the third change record and the fourth change record are identified according to the self-increment identifier, the last value of the change field is obtained in the third change record, and the current value of the change field is obtained in the fourth change record to obtain the change result; The change type of the change field of the eighth value is set to deletion, the third change record is identified according to the self-increment identifier, the last value of the change field is obtained in the third change record, and the change result is obtained.

6. The method for recording data changes in a data table according to claim 4, characterized in that: Generating a change result according to the change record includes: When the change record includes a first change record and a second change record, determining a field in the second change record whose value is a fourth value as a changed field; The change type of the changed field is set to new addition, and the current value of the changed field is obtained in the first change record to obtain the change result.

7. The method for recording data changes in a data table according to claim 5 or 6, characterized in that: The displaying of the change result includes: When the change type is new addition, the current value in the change result is displayed with the first background color; When the change type is modification, the current value in the change result is displayed with a first background color, the last value in the change result is displayed with a second background color, and a strikethrough mark is set for the last value; When the change type is deletion, the last value in the change result is displayed with a second background color, and a deletion line mark is set for the last value.

8. A data table data change recording device, characterized in that: The device comprises: A selection module, used to select a data table using a log table generator, and generate an operation log table and a status log table according to the data table, wherein the operation log table is used to record the change type of the data table and the data before and after the change, and the status log table is used to record the change status of the data table, and the operation log table and the status log table are associated through the same universal unique identifier UUID; A generating module, used for generating corresponding triggers according to the change type by using a trigger generator when the data in the data table is changed; A recording module, configured to insert a change record in the operation log table and the status log table based on the inserted data by using a corresponding first trigger when the change type is inserting data; The recording module is further configured to, when the change type is data modification, insert a change record into the operation log table and the status log table based on the modification data using a corresponding second trigger.

9. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the data change recording method of the data table according to any one of claims 1 to 7.

10. A computer device, characterized in that: The computer device comprises: a data change recording device of the data table as claimed in claim 8.