A data comparison method and apparatus, and an electronic device
By combining the data layer and the business layer for comparison, the problem of not being able to conduct full-coverage testing during database migration in existing technologies is solved, and consistency verification of data and business logic is achieved, improving the efficiency and accuracy of migration verification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PING AN BANK CO LTD
- Filing Date
- 2023-04-12
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies only verify table structure and tablespace information during database migration, failing to perform full-coverage testing of business processes, resulting in insufficient data consistency verification.
During the database migration process, a combination of data layer comparison and business layer comparison is used to generate a first comparison result and a second comparison result, which comprehensively verifies the consistency of data and business logic, including monitoring the data writing process and dual write permission control.
It enables comprehensive consistency verification of migrated data, improves testing efficiency and accuracy, supports batch testing, and ensures full coverage of business processes.
Smart Images

Figure CN116431610B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a data comparison method, apparatus, and electronic device. Background Technology
[0002] Data migration is largely considered an unavoidable process. When an enterprise uses a variety of databases, or when there is a need to change the type of database, significant data migration work may be required.
[0003] Migration can be considered a type of synchronization. Synchronization focuses on incremental changes, while migration focuses on full migration. Migration typically refers to the relocation of a database, moving the source database to a destination database. After the migration, the destination database replaces the source database to continue providing services, while the source database can choose to go offline or continue providing services. Throughout the migration process, verifying the migrated data is crucial, requiring not only verification of database table combinations and data consistency, but also comprehensive verification from the business logic level.
[0004] Currently, when migrating a database, consistency checks are performed on the table structure and tablespace information only, and cannot provide full coverage testing of the business processes.
[0005] Therefore, existing technologies still need to be improved and developed. Summary of the Invention
[0006] In view of the shortcomings of the prior art, the present invention provides a data comparison method, apparatus and electronic device, which aims to solve the problem that in the prior art, when database migration, data consistency verification only verifies and compares table structure and tablespace related information, and cannot perform full coverage testing of business processes.
[0007] The technical solution of the present invention is as follows:
[0008] The first embodiment of the present invention provides a data comparison method, the method comprising:
[0009] When migrating data from the original database to the target database, if a data write command is detected, data is written based on the data write command.
[0010] Once data writing is complete, perform a data-level comparison between the original database and the target database to generate the first comparison result.
[0011] Based on a pre-built business test plan, a business-level comparison is performed between the original database and the target database to generate a second comparison result.
[0012] Based on the first and second comparison results, the target data comparison results are generated.
[0013] Furthermore, when migrating data from the original database to the target database, if a data write instruction is detected, data is written based on the data write instruction, including:
[0014] Based on data migration instructions, migrate data from the original database to the target database;
[0015] If a data write command is detected, the data to be written is obtained and written to the original database.
[0016] Determine whether dual write permissions are enabled;
[0017] If dual write permissions are enabled, the data to be written will be written to the target database.
[0018] Furthermore, before obtaining the data to be written and writing the data to be written to the original database if a data write instruction is detected, the process further includes:
[0019] A listener is pre-configured to monitor the data writing process of the original database.
[0020] Furthermore, the step of obtaining the data to be written and writing the data to be written to the original database after detecting a data write instruction also includes:
[0021] Based on the monitoring program, determine whether to continue enabling dual write permissions;
[0022] If dual write permissions are not enabled, the data write operation to the target database will be terminated.
[0023] Furthermore, if dual write permissions are enabled, the data to be written is written to the target database, including:
[0024] If dual write permissions are enabled, the operation of writing the data to be written to the target database will be initiated.
[0025] Retrieve the write results to the target database;
[0026] If the write operation to the target database fails, a scheduled task will be started to re-execute the data write operation to the target database.
[0027] Further, upon detecting that data writing is complete, a data-level comparison is performed between the original database and the target database to generate a first comparison result, including:
[0028] Once data writing is complete, a data layer comparison task is created.
[0029] Read the first data at a predetermined ratio from the original database;
[0030] Based on the data ID of the first data, retrieve the corresponding second data from the target database;
[0031] The first data is compared with the second data to generate the first comparison result.
[0032] Furthermore, the comparison of the original database and the target database at the business level based on the pre-built business test plan generates a second comparison result, including:
[0033] Pre-assemble business process cases to complete the test plan construction;
[0034] The data from the original database is passed into the test plan and run to generate the first run result;
[0035] The data from the target database is passed into the test plan and run to generate a second set of results.
[0036] The first running result is compared with the second running result to generate a second comparison result.
[0037] Another embodiment of the present invention provides a data comparison device, the device comprising:
[0038] The source data writing module is used to write data based on a data writing instruction if a data writing instruction is detected when migrating data from the original database to the target database.
[0039] The data layer comparison module is used to detect when data writing is complete, perform a data layer comparison between the original database and the target database, and generate the first comparison result.
[0040] The business layer comparison module is used to compare the original database and the target database at the business layer based on a pre-built business test plan and generate a second comparison result.
[0041] The target result generation module is used to generate target data comparison results based on the first comparison result and the second comparison result.
[0042] Another embodiment of the present invention provides an electronic device, the electronic device including at least one processor; and,
[0043] A memory communicatively connected to the at least one processor; wherein,
[0044] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the data comparison method described above.
[0045] Another embodiment of the present invention provides a non-volatile computer-readable storage medium storing computer-executable instructions that, when executed by one or more processors, cause the one or more processors to perform the data comparison method described above.
[0046] Beneficial effects: The data comparison method of this invention compares the migrated data, not only at the data level but also at the business process results, and automatically outputs the comparison results. This can more effectively verify whether the migrated data and business layer are consistent. It also supports batch testing, improving testing efficiency and accuracy. Attached Figure Description
[0047] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings:
[0048] Figure 1 This is a flowchart of a preferred embodiment of a data comparison method according to the present invention;
[0049] Figure 2 This is a detailed flowchart of step S100 in a specific application embodiment of the data comparison method of the present invention.
[0050] Figure 3 This is a schematic diagram of the functional modules of a preferred embodiment of the data comparison device of the present invention;
[0051] Figure 4 This is a functional module diagram of the data writing module 11 in a specific application embodiment of a data comparison device of the present invention.
[0052] Figure 5 This is a schematic diagram of the hardware structure of a preferred embodiment of an electronic device according to the present invention. Detailed Implementation
[0053] To make the objectives, technical solutions, and effects of this invention clearer and more explicit, the invention is further described in detail below. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0054] The embodiments of the present invention will be described below with reference to the accompanying drawings.
[0055] To address the above problems, embodiments of the present invention provide a data comparison method. Please refer to [link / reference]. Figure 1 , Figure 1 This is a flowchart illustrating a preferred embodiment of a data comparison method according to the present invention. Figure 1 As shown, it includes:
[0056] Step S100: When migrating data from the original database to the target database, if a data write instruction is detected, data is written based on the data write instruction.
[0057] Step S200: After detecting that the data writing is complete, perform a data layer comparison between the original database and the target database to generate the first comparison result;
[0058] Step S300: Based on the pre-built business test plan, perform a business-level comparison between the original database and the target database to generate a second comparison result;
[0059] Step S400: Based on the first comparison result and the second comparison result, generate the target data comparison result.
[0060] In specific implementation, this invention is applied to a data comparison method after data migration during the "de-Oracle" process. "De-Oracle" refers to migrating an Oracle database to another database. Oracle database, also known as Oracle RDBMS, or simply Oracle, is a relational database management system. It boasts good portability, ease of use, and powerful functionality, suitable for various large, medium, and small computer environments. It is a highly efficient, reliable database solution adapted to high throughput. This invention pre-migrates data from the Oracle database to another database, where the Oracle database is the original database, and the migrated database is denoted as the target database. This invention uses a MySQL database as an example for illustration.
[0061] For historical data, migration is less difficult than for data currently being written. However, for data that undergoes writing changes during migration, this embodiment describes the data writing process. Upon detecting a data write command, the data to be written is written based on the command. This write operation may involve writing only the data to be written to the Oracle source database, or writing the data to be written to both the Oracle source database and the MySQL target database simultaneously.
[0062] After the data is written, the migrated data is compared. The data migration is divided into two parts: data layer comparison and business logic layer comparison.
[0063] The original database and the target database are compared at the data layer to generate the first comparison result, thus completing the data layer comparison. Based on the pre-built business test plan, the original database and the target database are compared at the business layer to generate the second comparison result, thus completing the business logic layer comparison. Based on the first and second comparison results, the target data comparison result between the original database and the target database is generated.
[0064] Subsequent program developers can then perform corresponding operations based on the comparison results.
[0065] This invention provides an automated method for data consistency verification and business logic layer consistency verification by illustrating the dual-write process during data migration from an Oracle database to a MySQL database and the subsequent data comparison. This ensures data integrity and consistency, significantly improving migration verification efficiency.
[0066] In one embodiment, such as Figure 2 As shown, step S100 includes:
[0067] Step S101: Based on the data migration instructions, migrate the data from the original database to the target database;
[0068] Step S102: If a data write command is detected, the data to be written is obtained and written to the original database.
[0069] Step S103: Determine whether dual write permission is enabled. If yes, proceed to step S104; otherwise, proceed to step S105.
[0070] Step S104: Write the data to be written into the target database;
[0071] Step S105: Do not perform a write operation to the target database.
[0072] In practice, historical data is easier to migrate than data currently being written. For data that is being migrated while data is being written, a dual-write scheme is used to control this. The design phase determines when the dual-write switch should be enabled, how it should be enabled in a distributed manner, how exceptions should be handled, and whether the process can be blocked.
[0073] Specifically, based on the data writing procedure, writes to the Oracle raw database; determines whether dual write permissions are enabled:
[0074] If dual write permissions are enabled, the data to be written will be written to the target database. Dual write permissions can act as a read / write switch, allowing for precise control over data capture.
[0075] In one embodiment, if a data write instruction is detected, the data to be written is obtained, and before writing the data to be written to the original database, the method further includes:
[0076] A listener is pre-configured to monitor the data writing process of the original database.
[0077] In practice, a binlog listener is pre-configured to monitor the data writing process of the original database. The binlog is a binary log that records all database table structure changes (such as CREATE, ALTER TABLE, etc.) and table data modifications (INSERT, UPDATE, DELETE, etc.). The binlog does not record operations like SELECT and SHOW, because these operations do not modify the data itself; however, all statements executed by MySQL can be viewed by querying the general log.
[0078] In one embodiment, if a data write instruction is detected, the data to be written is obtained, and after writing the data to be written to the original database, the method further includes:
[0079] Based on the aforementioned monitoring program, determine whether to continue enabling dual write permissions;
[0080] If dual write permissions are not enabled, the data write operation to the target database will be terminated.
[0081] In practice, a binlog listener is used to monitor the data writing process. Based on the binlog listener, it is determined whether to continue to enable dual write permissions. If dual write permissions are enabled, the data to be written is written to both the original database and the target database at the same time.
[0082] If dual write permissions are no longer enabled, the data to be written will no longer be written to the target database, but only to the original database.
[0083] In one embodiment, if dual write permissions are enabled, the data to be written is written to the target database, including:
[0084] If dual write permissions are enabled, the operation of writing the data to be written to the target database will be initiated.
[0085] Retrieve the write results to the target database;
[0086] If the write operation to the target database fails, a scheduled task will be started to re-execute the data write operation to the target database.
[0087] In practice, dual writes are initiated to synchronously write to the target MySQL database. If a write fails, a scheduled task is subsequently started to rewrite the data.
[0088] In one embodiment, upon detecting that data writing is complete, a data-level comparison is performed between the original database and the target database to generate a first comparison result, including:
[0089] Once data writing is complete, a data layer comparison task is created.
[0090] Read the first data at a predetermined ratio from the original database;
[0091] Based on the data ID of the first data, retrieve the corresponding second data from the target database;
[0092] The first data is compared with the second data to generate the first comparison result.
[0093] In practice, a data layer comparison task is created; a certain proportion of data is read from the Oracle database, and a corresponding certain proportion of data is synchronously pulled from the target database based on the data ID for comparison; the two data are compared to determine whether the basic information such as data field type, number of fields, and field values are consistent; the first comparison result is output. If the data is consistent, a consistency report is generated; if the data is inconsistent, the inconsistent data is output, and the reasons for the inconsistent data are analyzed.
[0094] In one embodiment, a business-level comparison is performed between the original database and the target database based on a pre-built business test plan to generate a second comparison result, including:
[0095] Pre-assemble business process cases to complete the test plan construction;
[0096] The data from the original database is passed into the test plan and run to generate the first run result;
[0097] The data from the target database is passed into the test plan and run to generate a second set of results.
[0098] The first running result is compared with the second running result to generate a second comparison result.
[0099] In practice, data layer comparison alone can only perform basic data verification and cannot conduct in-depth comparison of internal business logic.
[0100] The steps for comparing internal business logic are as follows:
[0101] Build a test plan by assembling business process cases. A test plan is composed of different cases assembled into a process. The design adopted in the cases is that the data source information and domain name information are separated from the execution script. In the actual execution of the two databases, the scripts are the same and remain unchanged, controlling a single variable. The only change is the change of the data source before and after.
[0102] Test plan execution: Input the preceding and following data sources, then execute;
[0103] Result comparison: Compare the two sets of results;
[0104] Display Inconsistency Reports: If inconsistencies occur in the output of business processes during execution, a report will be generated.
[0105] And analyze the inconsistencies.
[0106] As can be seen from the above method embodiments, the data comparison method after data migration during the O removal process of this invention collects data in parallel and performs data comparison, with the comparison accurate to each field. It not only compares the data at the data level but also proposes to assemble a test plan. In this case, the script and data source information are separated, and a single variable is controlled to compare the results of the business process, automatically outputting inconsistency reports. This process can more effectively verify whether the data after migration is consistent, whether the business layer is consistent, and more comprehensively verify the consistency of the data. It also supports batch testing, improving testing efficiency and accuracy. Furthermore, it can execute and compare regression test cases involving the business function module, achieving full coverage testing of the migrated business process.
[0107] It should be noted that there is no necessary order between the above steps. Those skilled in the art will understand from the description of the embodiments of the present invention that the above steps may have different execution orders in different embodiments, that is, they may be executed in parallel or in turn, etc.
[0108] Another embodiment of the present invention provides a data comparison device, such as... Figure 3 As shown, device 1 includes:
[0109] The data writing module 11 is used to write data based on the data writing instruction if a data writing instruction is detected when migrating data from the original database to the target database.
[0110] The data layer comparison module 12 is used to detect when the data writing is complete, perform a data layer comparison between the original database and the target database, and generate the first comparison result.
[0111] The business layer comparison module 13 is used to compare the original database and the target database at the business layer level based on a pre-built business test plan and generate a second comparison result.
[0112] The target result generation module 14 is used to generate target data comparison results based on the first comparison result and the second comparison result.
[0113] For specific implementation details, please refer to the method embodiment; they will not be repeated here.
[0114] In one embodiment, such as Figure 4 As shown, the data writing module 11 includes:
[0115] Data migration unit 111 is used to migrate data from the original database to the target database based on data migration instructions;
[0116] The first data writing unit 112 is used to obtain the data to be written and write the data to be written into the original database if a data writing instruction is detected.
[0117] Judgment unit 113 is used to determine whether dual write permission is enabled;
[0118] The second data writing unit 114 is used to write the data to be written to the target database if dual write permissions are enabled.
[0119] For specific implementation details, please refer to the method embodiment; they will not be repeated here.
[0120] In one embodiment, the apparatus further includes:
[0121] A pre-configured module is used to monitor the process of the program writing data to the original database.
[0122] For specific implementation details, please refer to the method embodiment; they will not be repeated here.
[0123] In one embodiment, the device further includes a control module, which is specifically used for:
[0124] Based on the aforementioned monitoring program, determine whether to continue enabling dual write permissions;
[0125] If dual write permissions are not enabled, the data write operation to the target database will be terminated.
[0126] For specific implementation details, please refer to the method embodiment; they will not be repeated here.
[0127] In one embodiment, the second data writing unit 114 is further configured to:
[0128] If dual write permissions are enabled, the operation of writing the data to be written to the target database will be initiated.
[0129] Retrieve the write results to the target database;
[0130] If the write operation to the target database fails, a scheduled task will be started to re-execute the data write operation to the target database.
[0131] For specific implementation details, please refer to the method embodiment; they will not be repeated here.
[0132] In one embodiment, the data layer comparison module 12 is specifically used for:
[0133] Once data writing is complete, a data layer comparison task is created.
[0134] Read the first data at a predetermined ratio from the original database;
[0135] Based on the data ID of the first data, retrieve the corresponding second data from the target database;
[0136] The first data is compared with the second data to generate the first comparison result.
[0137] For specific implementation details, please refer to the method embodiment; they will not be repeated here.
[0138] In one embodiment, the business layer comparison module 13 is specifically used for:
[0139] Pre-assemble business process cases to complete the test plan construction;
[0140] The data from the original database is passed into the test plan and run to generate the first run result;
[0141] The data from the target database is passed into the test plan and run to generate a second set of results.
[0142] The first running result is compared with the second running result to generate a second comparison result.
[0143] For specific implementation details, please refer to the method embodiment; they will not be repeated here.
[0144] Another embodiment of the present invention provides an electronic device, such as... Figure 5 As shown, the electronic device 10 includes:
[0145] One or more processors 110 and memory 120, Figure 5 The following description uses a processor 110 as an example. The processor 110 and the memory 120 can be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.
[0146] Processor 110 is used to perform various control logics of electronic device 10. It can be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), microcontroller, ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware controls, or any combination of these components. Furthermore, processor 110 can also be any conventional processor, microprocessor, or state machine. Processor 110 can also be implemented as a combination of computing devices, such as a combination of DSP and microprocessor, multiple microprocessors, one or more microprocessors combined with a DSP core, or any other such configuration.
[0147] The memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions corresponding to the data comparison method in the embodiments of the present invention. The processor 110 executes various functional applications and data processing of the device 10 by running the non-volatile software programs, instructions, and units stored in the memory 120, thereby implementing the data comparison method in the above-described method embodiments.
[0148] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store applications required for operating the device and at least one function; and the data storage area may store data created according to the use of the device 10. Furthermore, the memory 120 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include memory remotely located relative to the processor 110, and these remote memories may be connected to the device 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0149] One or more units are stored in memory 120, and when executed by one or more processors 110, they perform the data comparison method in any of the above method embodiments, for example, the method described above. Figure 1 Method steps S100 to S400.
[0150] This invention provides a non-volatile computer-readable storage medium storing computer-executable instructions that are executed by one or more processors, for example, to perform the operations described above. Figure 1 Method steps S100 to S400.
[0151] As an example, non-volatile storage media can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) as an external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The memory controls or memories disclosed in the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.
[0152] Another embodiment of the present invention provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium. The computer program includes program instructions that, when executed by a processor, cause the processor to perform the data comparison method of the above-described method embodiments. For example, performing the above-described... Figure 1 Method steps S100 to S400.
[0153] The embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0154] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general-purpose hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can exist in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0155] Among other things, conditional language such as “can,” “may,” “may,” or “may,” unless otherwise specifically stated or otherwise understood as in the context in which they are used, is generally intended to convey that a particular implementation may include (but not others) certain features, elements, and / or operations. Therefore, such conditional language is also generally intended to imply that features, elements, and / or operations are necessary for one or more implementations in any way, or that one or more implementations must include logic for determining, with or without input or prompting, whether such features, elements, and / or operations are included or will be performed in any particular implementation.
[0156] The contents already described herein in this specification and accompanying drawings include examples of methods and apparatuses capable of providing data comparison. It is certainly not possible to describe every conceivable combination of elements and / or methods for the purpose of describing the various features of this disclosure, but it will be appreciated that many other combinations and substitutions of the disclosed features are possible. Therefore, it will be apparent that various modifications can be made to this disclosure without departing from the scope or spirit of this disclosure. Furthermore, or in alternatives, other embodiments of this disclosure may become apparent from consideration of this specification and accompanying drawings and from practice of this disclosure as presented herein. It is intended that the examples presented in this specification and accompanying drawings be considered illustrative rather than restrictive in all respects. Although specific terminology is used herein, it is used in a general and descriptive sense and is not intended for limiting purposes.
Claims
1. A data comparison method, characterized in that... The method includes: Before migrating data from the original database to the target database, a listener is pre-configured to monitor the data writing process in the original database. Based on data migration instructions, migrate data from the original database to the target database; If a data write command is detected, the data to be written is obtained and written to the original database. Determine whether dual write permissions are enabled; If dual write permissions are enabled, the data to be written will be written to the target database. Based on the aforementioned monitoring program, determine whether to continue enabling dual write permissions; If dual write permissions are enabled, the data to be written will be written to both the original database and the target database simultaneously. If dual write permissions are not enabled, the data write operation to the target database will be terminated, and the data to be written will be written to the original database. Once data writing is complete, perform a data-level comparison between the original database and the target database to generate the first comparison result. Based on a pre-built business test plan, a business-level comparison is performed between the original database and the target database to generate a second comparison result. Based on the first and second comparison results, the target data comparison results are generated.
2. The method according to claim 1, characterized in that, If dual write permissions are enabled, the data to be written is written to the target database, including: If dual write permissions are enabled, the operation of writing the data to be written to the target database will be initiated. Retrieve the write results to the target database; If the write operation to the target database fails, a scheduled task will be started to re-execute the data write operation to the target database.
3. The method according to claim 2, characterized in that, Upon detecting that data writing is complete, a data-level comparison is performed between the original database and the target database to generate a first comparison result, including: Once data writing is complete, a data layer comparison task is created. Read the first data at a predetermined ratio from the original database; Based on the data ID of the first data, retrieve the corresponding second data from the target database; The first data is compared with the second data to generate the first comparison result.
4. The method according to claim 3, characterized in that, The process involves comparing the original database and the target database at the business level based on a pre-built business test plan, generating a second comparison result, including: Pre-assemble business process cases to complete the test plan construction; The data from the original database is passed into the test plan and run to generate the first run result; The data from the target database is passed into the test plan and run to generate a second set of results. The first running result is compared with the second running result to generate a second comparison result.
5. A data comparison device, characterized in that, The device includes: The data writing module is used to write data based on the data writing instruction if a data writing instruction is detected when migrating data from the original database to the target database. The data layer comparison module is used to detect when data writing is complete, perform a data layer comparison between the original database and the target database, and generate the first comparison result. The business layer comparison module is used to compare the original database and the target database at the business layer based on a pre-built business test plan and generate a second comparison result. The target result generation module is used to generate target data comparison results based on the first comparison result and the second comparison result; Before migrating data from the original database to the target database, a listener is pre-configured to monitor the data writing process in the original database. When migrating data from the original database to the target database, if a data write instruction is detected, data is written based on the data write instruction, including: Based on data migration instructions, migrate data from the original database to the target database; If a data write command is detected, the data to be written is obtained and written to the original database. Determine whether dual write permissions are enabled; If dual write permissions are enabled, the data to be written will be written to the target database. Based on the aforementioned monitoring program, determine whether to continue enabling dual write permissions; If dual write permissions are enabled, the data to be written will be written to both the original database and the target database simultaneously. If dual write permissions are not enabled, the data write operation to the target database will be terminated, and the data to be written will be written to the original database.
6. An electronic device, characterized in that, The electronic device includes at least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the data comparison method according to any one of claims 1-4.
7. A non-volatile computer-readable storage medium, characterized in that, The non-volatile computer-readable storage medium stores computer-executable instructions that, when executed by one or more processors, cause the one or more processors to perform the data comparison method according to any one of claims 1-4.