Search

CN-122019551-A - Data change recording method, device, computer equipment and storage medium

CN122019551ACN 122019551 ACN122019551 ACN 122019551ACN-122019551-A

Abstract

The application relates to a data change recording method, a data change recording device, computer equipment and a storage medium. The method comprises the steps of analyzing a data operation request by utilizing a data mapping tool, so as to obtain a target data field of an operation requested by the data operation request, a target service table where the target data field is located, a target operation type and a target history table associated with the target service table, forming a change record by changing a data value of the target data field from a first data value to a second data value according to the target operation type, and storing the change record in the target history table, thereby realizing automatic record of data change without manual pre-annotation and manual intervention, and further solving the problem of how to realize automatic record of data change without manual pre-annotation and manual intervention.

Inventors

  • SUI BOWEN

Assignees

  • 北京金山云网络技术有限公司

Dates

Publication Date
20260512
Application Date
20241111

Claims (10)

  1. 1. A method of data change recording, the method comprising: When a data operation request is received, analyzing the data operation request by using a data mapping tool to obtain data operation information, wherein the data operation request is used for requesting to change a data value of a target data field in a target service table from a first data value to a second data value, and the data operation information comprises a target operation type, a target data field, a target service table and a target history table corresponding to the target service table; Changing the data value of the target data field in the target service table from a first data value to a second data value according to the target operation type; generating a change record corresponding to the target data field according to the operation process of changing the data value of the target data field from the first data value to the second data value in the target service table and the data operation information; And saving the change record corresponding to the target data field to the target history table.
  2. 2. The method of claim 1, wherein changing the data value of the target data field in the target service table from the first data value to the second data value according to the target operation type comprises: Changing the data value of the target data field in the target service table from a first data value to a second data value according to the target operation type by using a data processing thread; after the data processing thread changes the data value of the target data field in the target service table from the first data value to the second data value according to the target operation type, the method further comprises: And acquiring an operation object tag corresponding to the data operation request according to the thread local variable corresponding to the data processing thread, wherein the operation object tag corresponding to the data operation request is used for participating in generating a change record corresponding to the target data field.
  3. 3. The method of claim 2, wherein before generating the change record corresponding to the target data field according to the operation procedure of changing the data value of the target data field from the first data value to the second data value in the target service table and the data operation information, the method further comprises: the receiving time of the data operation request is taken as the corresponding operation time of the data operation request, or, And changing the data value of the target data field in the target service table from a first data value to a second data value by the data processing thread according to the target operation type to serve as operation time corresponding to the data operation request, wherein the operation time corresponding to the data operation request is used for participating in generating a change record corresponding to the target data field.
  4. 4. The method of claim 3, wherein generating the change record corresponding to the target data field according to the operation procedure of changing the data value of the target data field from the first data value to the second data value in the target service table and the data operation information, comprises: And generating a change record corresponding to the target data field according to the operation process of changing the data value of the target data field from the first data value to the second data value, the target operation type, the target data field, the operation object label and the operation time corresponding to the data operation request in the target service table.
  5. 5. The method of claim 4, wherein generating a change record corresponding to the target data field according to an operation procedure of changing the data value of the target data field from the first data value to the second data value in the target service table, the target operation type, the target data field, the operation object tag, and an operation time corresponding to the data operation request, comprises: And when the target operation type is the added data, generating a change record corresponding to the target data field according to a second data value corresponding to the target operation type, an added identifier corresponding to the target operation type, the target data field, the operation object tag and the operation time corresponding to the data operation request.
  6. 6. The method of claim 4, wherein generating a change record corresponding to the target data field according to an operation procedure of changing the data value of the target data field from the first data value to the second data value in the target service table, the target operation type, the target data field, the operation object tag, and an operation time corresponding to the data operation request, comprises: When the target operation type is update data, generating a first update record corresponding to the target data field according to a first data value before updating the target data field, a first update identifier corresponding to the target operation type, the target data field, the operation object tag and operation time corresponding to the data operation request; Generating a second update record corresponding to the target data field according to the updated second data value of the target data field, a second update identifier corresponding to the target operation type, the target data field, the operation object tag and the operation time corresponding to the data operation request, wherein the change record corresponding to the target data field comprises the first update record and the second update record.
  7. 7. The method of claim 4, wherein generating a change record corresponding to the target data field according to an operation procedure of changing the data value of the target data field from the first data value to the second data value in the target service table, the target operation type, the target data field, the operation object tag, and an operation time corresponding to the data operation request, comprises: And when the target operation type is deleted data, generating a change record corresponding to the target data field according to a first data value before updating the target data field, a deletion identifier corresponding to the target operation type, the target data field, the operation object label and the operation time corresponding to the data operation request.
  8. 8. A data change recording device, the device comprising: The system comprises an analysis module, a data mapping module and a data operation module, wherein the analysis module is used for analyzing a data operation request by utilizing a data mapping tool when the data operation request is received to obtain data operation information, the data operation request is used for requesting to change a data value of a target data field in a target service table from a first data value to a second data value, and the data operation information comprises a target operation type, a target data field, a target service table and a target history table corresponding to the target service table; The execution module is used for changing the data value of the target data field in the target service table from a first data value to a second data value according to the target operation type; The recording module is used for generating a change record corresponding to the target data field according to the operation process of changing the data value of the target data field from the first data value to the second data value in the target service table and the data operation information; And the storage module is used for storing the change record corresponding to the target data field into the target history table.
  9. 9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the data change recording method of any of claims 1 to 7 when the computer program is executed by the processor.
  10. 10. A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program, when executed by a processor, implements the data change recording method of any one of claims 1 to 7.

Description

Data change recording method, device, computer equipment and storage medium Technical Field The present application relates to the field of computer technologies, and in particular, to a data change recording method, apparatus, computer device, and storage medium. Background The method comprises the steps that firstly, professional database operators manually analyze and store a certain data operation record by adopting a binlog technology, the method needs manual intervention of professional personnel, automatic recording of data change in the database cannot be achieved, secondly, each data operation is recorded, the method is high in code invasiveness and unfriendly to subsequent updating iteration, thirdly, data operation analysis is conducted based on a service section and annotation, and research and development personnel are required to add corresponding annotations in a development stage to achieve the data change record, so that maintainability is low. Disclosure of Invention The application provides a data change recording method, a device, computer equipment and a storage medium, which are used for solving the problem of how to realize automatic recording of data change without manual pre-annotation and manual intervention. In a first aspect, the present application provides a data change recording method, the method including: When a data operation request is received, analyzing the data operation request by using a data mapping tool to obtain data operation information, wherein the data operation request is used for requesting to change a data value of a target data field in a target service table from a first data value to a second data value, and the data operation information comprises a target operation type, a target data field, a target service table and a target history table corresponding to the target service table; Changing the data value of the target data field in the target service table from a first data value to a second data value according to the target operation type; generating a change record corresponding to the target data field according to the operation process of changing the data value of the target data field from the first data value to the second data value in the target service table and the data operation information; And saving the change record corresponding to the target data field to the target history table. In a second aspect, the present application provides a data change recording apparatus, the apparatus comprising: The system comprises an analysis module, a data mapping module and a data operation module, wherein the analysis module is used for analyzing a data operation request by utilizing a data mapping tool when the data operation request is received to obtain data operation information, the data operation request is used for requesting to change a data value of a target data field in a target service table from a first data value to a second data value, and the data operation information comprises a target operation type, a target data field, a target service table and a target history table corresponding to the target service table; The execution module is used for changing the data value of the target data field in the target service table from a first data value to a second data value according to the target operation type; The recording module is used for generating a change record corresponding to the target data field according to the operation process of changing the data value of the target data field from the first data value to the second data value in the target service table and the data operation information; And the storage module is used for storing the change record corresponding to the target data field into the target history table. In a third aspect, the present application provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above-described data change recording method when executing the computer program. In a fourth aspect, the present application also provides a computer storage medium storing computer executable instructions for performing the above-described data change recording method. Compared with the prior art, the method provided by the embodiment of the application has the advantages that when a data operation request is received, the data operation request is analyzed by utilizing a data mapping tool to obtain data operation information, wherein the data operation request is used for requesting to change a data value of a target data field in a target service table from a first data value to a second data value, the data operation information comprises a target operation type, a target data field, a target service table and a target history table corresponding to the target service table, the data value of the target data field in the target service table is changed from the first data value to the second