Database synchronization verification method, device, equipment and storage medium

By parsing and verifying table structure and record consistency during database synchronization, the problem of lack of automated detection of data differences in the existing technology is solved, and detection accuracy and efficiency are improved.

CN112307124BActive Publication Date: 2024-09-27SHENZHEN SHENQUAN INTERACTIVE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011207860.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-03
Publication Date
2024-09-27
Estimated Expiration
2040-11-03

AI Technical Summary

Technical Problem

The existing database synchronization process lacks a mechanism to automatically detect data differences, resulting in testers needing to manually check, which is a heavy workload, error-prone, and low efficiency.

Method used

Provides a database synchronization verification method. By receiving the GG synchronization request between the source database and the target database, parsing the table structure definition, verifying the table structure and record synchronization consistency, and outputting the verification results at the end of the data synchronization, realizing automatic data detection .

Benefits of technology

It improves the accuracy and efficiency of data detection during the database synchronization process, reduces the error rate of manual inspection, and realizes automated data difference detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112307124B
    Figure CN112307124B
Patent Text Reader

Abstract

The present invention relates to the field of big data, and discloses a database synchronization verification method, device, equipment and storage medium. The method comprises: receiving a GG synchronization request between a source database and a target database and performing GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method; parsing the GG synchronization request to obtain the owner name and table name of the source table and the target table; verifying whether the table structure definition of the source table and the target table is correct; then verifying whether each record of the source table is correctly synchronized to the target table; then at the end of the GG synchronization, verifying whether the number of records in the source table and the target table is consistent; and finally outputting the GG synchronization verification result between the source database and the target database. The present invention also relates to blockchain technology, and the source table and the target table are stored in the blockchain. The present invention realizes the automatic detection of GG synchronized data, and improves the detection accuracy and efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to big data, and in particular to a database synchronization verification method, device, equipment and storage medium. Background Art

[0002] Database synchronization is required in some application scenarios. For example, in test scenarios, the GG (GoldenGate, a log-based structured data replication and backup software) synchronization process is usually used to achieve data synchronization. The entire synchronization process cannot be paused, and any data changes in the source database will be synchronized to the target database.

[0003] Usually, if the GG synchronization process is not interrupted, there will be no data difference between the source database and the target database. Therefore, the existing GG synchronization process does not have data difference verification. When data differences occur during database synchronization, testers are usually required to manually check, which is labor-intensive and prone to errors, resulting in low test efficiency. Summary of the invention

[0004] The main purpose of the present invention is to solve the problem that the database synchronization process cannot automatically detect the differences of the synchronized data.

[0005] A first aspect of the present invention provides a database synchronization verification method, comprising:

[0006] Receiving a GG synchronization request between a source database and a target database and performing GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method;

[0007] Parse the GG synchronization request to obtain the owner name and table name of the source table, and obtain the owner name and table name of the target table;

[0008] Verify whether the table structure definitions of the source and target tables are correct based on the owner name and table name of the source table and the owner name and table name of the target table.

[0009] If the table structures of the source table and the target table are defined correctly, verify whether each record of the source table is correctly synchronized to the target table;

[0010] If each record of the source table is correctly synchronized to the target table, then at the end of GG synchronization, verify whether the number of records in the source table and the target table is consistent;

[0011] Output the GG synchronization verification results between the source database and the target database.

[0012] Optionally, in a first implementation of the first aspect of the present invention, verifying whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table includes:

[0013] According to the owner name and table name of the source table and the owner name and table name of the target table, determine whether the field type of each field in the source table and the target table is consistent and whether the field length of the target table is greater than or equal to the field length of the source table;

[0014] If the field type and field length of each field in the source table and the target table are correct, check whether the unique index name and column names of the target table exist in the source table;

[0015] If the unique index name and column names of the target table exist in the source table, make sure that the table structures of the source and target tables are defined correctly.

[0016] Optionally, in a second implementation of the first aspect of the present invention, if the table structures of the source table and the target table are correctly defined, verifying whether each record of the source table is correctly synchronized to the target table includes:

[0017] If the table structures of the source table and the target table are correctly defined, then the field value corresponding to each field in the source table is obtained from the preset configuration table according to the field type and field length of each field in the source table;

[0018] Execute the preset insert SQL statement to write the obtained field value of each field into the source table;

[0019] Execute the preset first query SQL statement to determine whether the target table contains the field value inserted in the source table and the corresponding field name is the same;

[0020] If the field value inserted in the source table exists in the target table and the corresponding field name is the same, the preset update SQL statement is executed to update the field value inserted in the source table;

[0021] Execute the preset second query SQL statement to determine whether the target table has the updated field value in the source table and the corresponding field name is the same;

[0022] If the updated field values ​​in the source table exist in the target table and the corresponding field names are the same, the preset delete SQL statement is executed to delete the updated field values ​​in the source table;

[0023] Execute the preset third query SQL statement to determine whether the updated field value in the source table synchronized in the target table has been deleted and whether the field name corresponding to the deleted field value is the same.

[0024] Optionally, in a third implementation of the first aspect of the present invention, if each record of the source table is correctly synchronized to the target table, then at the end of GG synchronization, verifying whether the number of records in the source table and the target table is consistent includes:

[0025] If each record of the source table is correctly synchronized to the target table, when the GG synchronization is completed, the first number of records of the source table and the second number of records of the target table are obtained respectively, and it is determined whether the first number of records is consistent with the second number of records.

[0026] Optionally, in a fourth implementation of the first aspect of the present invention, if each record of the source table is correctly synchronized to the target table, then at the end of the GG synchronization, after verifying whether the number of records in the source table and the target table is consistent, it further includes:

[0027] When data differences are detected during GG synchronization, the checkpoint where the data differences occur is recorded and a data difference description is generated.

[0028] Optionally, in a fifth implementation manner of the first aspect of the present invention, the source table and the target table are stored in a blockchain.

[0029] A second aspect of the present invention provides a database synchronization verification device, comprising:

[0030] A receiving module, used for receiving a GG synchronization request between a source database and a target database and performing GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method;

[0031] A parsing module, used for parsing the GG synchronization request, obtaining the owner name and table name of the source table, and obtaining the owner name and table name of the target table;

[0032] A first verification module is used to verify whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table;

[0033] The second verification module is used to verify whether each record of the source table is correctly synchronized to the target table if the table structures of the source table and the target table are correctly defined;

[0034] The third verification module is used to verify whether the number of records in the source table and the target table is consistent when the GG synchronization is completed if each record in the source table is correctly synchronized to the target table;

[0035] The output module is used to output the GG synchronization verification results between the source database and the target database.

[0036] Optionally, in a first implementation of the second aspect of the present invention, the first verification module includes:

[0037] A first determination unit is used to determine whether the field type of each field in the source table and the target table is consistent and whether the field length of the target table is greater than or equal to the field length of the source table according to the owner name and table name of the source table and the owner name and table name of the target table;

[0038] A search unit is used to search whether the unique index name and each column name of the target table exist in the source table if the field type and field length of each field in the source table and the target table are correct;

[0039] The determination unit is used to determine that the table structure definitions of the source table and the target table are correct if the unique index name and the column names of the target table exist in the source table.

[0040] Optionally, in a second implementation of the second aspect of the present invention, the second verification module includes:

[0041] An acquisition unit, configured to acquire a field value corresponding to each field from a preset configuration table according to a field type and a field length of each field in the source table if the table structures of the source table and the target table are correctly defined;

[0042] The second determination unit is used to execute the preset insert SQL statement to write the acquired field value of each field into the source table; execute the preset first query SQL statement to determine whether the field value inserted in the source table exists in the target table and the corresponding field name is the same;

[0043] The third determination unit is used to execute a preset update SQL statement to update the inserted field value in the source table if the field value inserted in the source table exists in the target table and the corresponding field name is the same; execute a preset second query SQL statement to determine whether the updated field value in the source table exists in the target table and the corresponding field name is the same;

[0044] The fourth judgment unit is used to execute a preset deletion SQL statement to delete the updated field value in the source table if the updated field value in the source table exists in the target table and the corresponding field name is the same; execute a preset third query SQL statement to determine whether the updated field value in the source table synchronized in the target table has been deleted and the field name corresponding to the deleted field value is the same.

[0045] Optionally, in a third implementation of the second aspect of the present invention, the third verification module is further used to:

[0046] If each record of the source table is correctly synchronized to the target table, when the GG synchronization is completed, the first number of records of the source table and the second number of records of the target table are obtained respectively, and it is determined whether the first number of records is consistent with the second number of records.

[0047] Optionally, in a fourth implementation of the second aspect of the present invention, the database synchronization verification device further includes:

[0048] The recording module is used to record the checkpoint where the data difference occurs and generate a data difference description when data differences are detected during the GG synchronization process.

[0049] Optionally, in a fifth implementation of the second aspect of the present invention, the source table and the target table are stored in a blockchain.

[0050] The third aspect of the present invention provides a database synchronization verification device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the database synchronization verification device executes the above-mentioned database synchronization verification method.

[0051] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned database synchronization verification method.

[0052] In the technical solution provided by the present invention, GG synchronization verification is performed after receiving a GG synchronization request; firstly, it is verified whether the table structure definitions of the source table and the target table are correct through the source table attribute name and table name in the GG synchronization request and the owner name and table name of the target table; then, it is verified whether each record of the source table is correctly synchronized to the target table; then, it is verified whether the number of records in the source table and the target table is consistent; finally, all the GG synchronization verification results of the source table and the target table by various methods are output to realize automatic detection of GG synchronized data and improve the accuracy and efficiency of detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 A schematic diagram of a first embodiment of a database synchronization verification method in an embodiment of the present invention;

[0054] Figure 2 A schematic diagram of a second embodiment of a database synchronization verification method in an embodiment of the present invention;

[0055] Figure 3 A schematic diagram of a third embodiment of the database synchronization verification method in an embodiment of the present invention;

[0056] Figure 4 A schematic diagram of a fourth embodiment of a database synchronization verification method according to an embodiment of the present invention;

[0057] Figure 5 A schematic diagram of an embodiment of a database synchronization verification device in an embodiment of the present invention;

[0058] Figure 6 A schematic diagram of another embodiment of a database synchronization verification device in an embodiment of the present invention;

[0059] Figure 7 The figure is a schematic diagram of an embodiment of a database synchronization verification device in an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The embodiment of the present invention provides a database synchronization verification method, device, equipment and storage medium, which receives a GG synchronization request between a source database and a target database and performs GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method; parses the GG synchronization request to obtain the owner name and table name of the source table and the target table; first verifies whether the table structure definition of the source table and the target table is correct; then verifies whether each record of the source table is correctly synchronized to the target table; then at the end of the GG synchronization, verifies whether the number of records in the source table and the target table is consistent; finally outputs the GG synchronization verification result between the source database and the target database. The present invention also relates to blockchain technology, wherein the source table and the target table are stored in a blockchain. The present invention realizes automatic detection of GG synchronized data, and improves detection accuracy and efficiency.

[0061] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0062] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 The first embodiment of the database synchronization verification method in the embodiment of the present invention includes:

[0063] 101. Receive a GG synchronization request between a source database and a target database and perform GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method;

[0064] It is understandable that the execution subject of the present invention can be a database synchronization verification device, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking the server as the execution subject as an example. It should be emphasized that in order to further ensure the privacy and security of the above-mentioned source table and target table, the above-mentioned source table and target table can also be stored in a node of a blockchain.

[0065] In this embodiment, after receiving the GG synchronization request, the source database performs GG synchronization data with the target database, and triggers verification of the synchronized data in the source database and the target database at the same time. In addition, this application verifies the synchronized data in the source database and the target database in six aspects.

[0066] 102. Parse the GG synchronization request to obtain the owner name and table name of the source table, and obtain the owner name and table name of the target table;

[0067] In this embodiment, when the source database performs GG synchronization with the target database, a GG synchronization request is initiated. The GG synchronization request contains the owner name and table name of each source table in the source database, as well as the owner name and table name of each target table in the corresponding target database, so as to determine the storage format and storage space content of the GG synchronization data.

[0068] 103. Verify whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table;

[0069] In this embodiment, the first aspect of GG synchronization is verified: the field type and field length of each field in the source table and the target table are compared to ensure that the field type is consistent and the field length of the target table is greater than or equal to the field length of the source table. Specifically, the following steps are included:

[0070] According to the owner name, connect the fields, field types, and field lengths of each source table in the source database and the corresponding target tables in the target database. The database here can be a SQL (Structured Query Language) database.

[0071] Determine whether the table names of each source table in the source database contain the table names of all target tables in the target database;

[0072] If they are included, the field types in the source table and the target table with the same table name are compared cyclically, and it is determined whether the field types are consistent and whether the field lengths meet the preset conditions;

[0073] If they are consistent and conform to the requirements, then all fields are determined to have passed the inspection; if they are inconsistent or do not conform to the requirements, then the inconsistent or non-conforming fields are determined to have failed the inspection, and a notification message indicating that the inspection has failed is output;

[0074] If not included, it is determined that the GG synchronization fails the check and a notification message of the check failure is output.

[0075] In this embodiment, the second aspect of GG synchronization is verified: whether the index value of each data in the source table contains the index value of all data in the target table. Specifically, the following steps are included:

[0076] Connect the index names of each source table in the source database and the corresponding target tables in the target database;

[0077] Based on the index name, determine all index values ​​in the source table and the target table;

[0078] Compare the index values ​​in the source table and the target table to determine whether the source table contains all the index values ​​of the target table;

[0079] If it is included, it is determined that all fields have passed the check; if it is not included, it is determined that the fields not included have failed the check, and a notification message of the check failure is output.

[0080] 104. If the table structures of the source table and the target table are defined correctly, verify whether each record of the source table is correctly synchronized to the target table;

[0081] In this embodiment, through the previous verification of the first and second aspects of GG synchronization, we obtain the field index, field type and field length of each field in the source table. Here, the third, fourth and fifth aspects of GG synchronization are verified. Among them, the third aspect is used to verify whether the insert fields of the source table and the target table in GG synchronization are the same, the fourth aspect is used to verify whether the update fields of the source table and the target table in GG synchronization are the same, and the fifth aspect is used to verify whether the delete fields of the source table and the target table in GG synchronization are the same. The specific verification steps are as follows:

[0082] Sequentially assign values ​​to each source table and each target table, and to the fields in each source table and each target table, to obtain corresponding field values;

[0083] Based on the field values ​​of the source table, each target table, and the field, concatenate the SQL statements corresponding to the fields inserted, updated, or deleted in the source table, and execute the SQL statements in the source database;

[0084] Check whether the target database has corresponding copy records with the same assigned content. If so, determine that all fields pass the check. Otherwise, determine that the fields with coded records fail the check, and output a notification message indicating that the check failed.

[0085] 105. If each record of the source table is correctly synchronized to the target table, then at the end of GG synchronization, verify whether the number of records in the source table and the target table is consistent;

[0086] In this embodiment, the sixth aspect of GG synchronization is verified: whether the number of records in the fields of the source table and the target table is consistent. Different types of databases can use corresponding field counting commands. Among them, verifying whether the number of records in the source table and the target table is consistent can be specifically done by obtaining the first number of records in the source table and the second number of records in the target table, and determining whether the first number of records is consistent with the second number of records.

[0087] 106. Output the GG synchronization verification result between the source database and the target database.

[0088] In this embodiment, the verification results of the first to sixth aspects in GG synchronization are output according to the display rules (such as the front-end display model), wherein the display rules limit the display area of ​​each verification result in the form of a display template.

[0089] In an embodiment of the present invention, after receiving a GG synchronization request, GG synchronization verification is performed; through the source table attribute name, table name and the target table owner name, table name in the GG synchronization request, it is verified whether the table structure definitions of the source table and the target table are correct; then it is verified whether each record of the source table is correctly synchronized to the target table; then it is verified whether the number of records in the source table and the target table is consistent; finally, all GG synchronization verification results of the source table and the target table are output to realize automatic detection of GG synchronized data and improve the accuracy and efficiency of detection.

[0090] See also Figure 2 The second embodiment of the database synchronization verification method in the embodiment of the present invention includes:

[0091] 201. Receive a GG synchronization request between a source database and a target database and perform GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method;

[0092] 202. Parse the GG synchronization request to obtain the owner name and table name of the source table, and obtain the owner name and table name of the target table;

[0093] 203. According to the owner name and table name of the source table and the owner name and table name of the target table, determine whether the field type of each field in the source table and the target table is consistent and whether the field length of the target table is greater than or equal to the field length of the source table;

[0094] In this embodiment, first compare whether the field types of the fields in the source table and the target table are consistent: first, according to the owner name, take out the table name and field type of the source table and the target table respectively, and then compare the differences between the table names and field types of the two. This can be directly executed through the database command line. For example, for an Oracle database, the following command can be used to verify the consistency of field types:

[0095] select.owner,T.TABLE_NAME,T.COLUMN_NAME,T.DATA_TYPE,T.DAT A_LENGTH

[0096] from all_tab_columns t where t.owner=UPPER('Owner Name')AND T.TABLE_NAME=UPPER('Table Name')

[0097] Then verify whether the field length of the target table is greater than or equal to the field length of the source table. You can sort the fields at the same position according to their ASCII code values, and then compare the lengths of the fields according to the sorting quantity. For example, if the fields of the source table are aceb and acebd, and the ASCII code value sorting order is: a<b<c<d<e, then the field length is abce<abcde.

[0098] 204. If the field type and field length of each field in the source table and the target table are correct, check whether the unique index name and each column name of the target table exist in the source table;

[0099] 205. If the unique index name and column names of the target table exist in the source table, make sure that the table structure definitions of the source table and the target table are correct.

[0100] In this embodiment, according to the owner name and table name of the source table and the owner name and table name of the target table, the index view of the corresponding storage field is obtained; the corresponding index table is created according to the index view, and filtered according to the index name in the index table; according to the index name remaining after filtering the corresponding index name of the target table, it can be determined whether the unique index name and each column name of the target table exist in the source table, and the index name that does not exist in the source table. The specific execution command line is as follows:

[0101] select t.table_owner,t.table_name,t.index_name,

[0102] t.column_name from all_ind_columns t,

[0103] all_indexes i where t.table_owner=i.table_owner and

[0104] t.index_name=i.index_name and

[0105] t.table_name=i.table_name and

[0106] i.uniqueness = 'UNIQUE' and

[0107] t.table_name=UPPER('table name')and

[0108] t.table_owner = UPPER('Owner name').

[0109] 206. If the table structures of the source table and the target table are defined correctly, verify whether each record of the source table is correctly synchronized to the target table;

[0110] 207. If each record of the source table is correctly synchronized to the target table, then at the end of GG synchronization, verify whether the number of records in the source table and the target table is consistent;

[0111] 208. Output the GG synchronization verification result between the source database and the target database.

[0112] In an embodiment of the present invention, verification of whether the table structure definitions of the source table and the target table are correct is introduced in detail. If the table name, primary attribute name, and field type, field length, and index name of the source table and the target table are consistent, it can be determined that the table structure definitions of the source table and the target table are correct, thus realizing the first round of layer verification of GG synchronization.

[0113] See also Figure 3 The third embodiment of the database synchronization verification method in the embodiment of the present invention includes:

[0114] 301. Receive a GG synchronization request between a source database and a target database and perform GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method;

[0115] 302. Parse the GG synchronization request to obtain the owner name and table name of the source table, and obtain the owner name and table name of the target table;

[0116] 303. Verify whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table;

[0117] 304. If the table structures of the source table and the target table are correctly defined, then according to the field type and field length of each field in the source table, a field value corresponding to each field is obtained from the preset configuration table;

[0118] In this embodiment, the field value assignment rules for each field type and field length are specified in the preset configuration table, and the field value is configured for each field. For example, for a field of type A and length range B, a fixed value a+fixed value b+sequential number (such as 1, 2, 3...) is used to obtain the field value corresponding to each field. In addition, each source table is sequentially numbered and inserted into the field value, and the final field value of each field is: sequential number+fixed value a+fixed value b+sequential number.

[0119] 305. Execute the preset insert SQL statement to write the acquired field value of each field into the source table;

[0120] In this embodiment, for the SQL database, the command line for inserting the field is configured as a preset insert SQL statement, which can be insert into table_name (source table name) value (field value). By inserting the SQL statement, the corresponding fields are assigned values, which is the action of writing to the source table.

[0121] 306. Execute the preset first query SQL statement to determine whether the target table has the field value inserted in the source table and the corresponding field name is the same;

[0122] In this embodiment, when the first query SQL statement in the source data is executed, the fields after the field values ​​are assigned will still be synchronized to the target database. Therefore, it is only necessary to query whether the fields of the corresponding target table in the target database are also assigned to determine whether the GG synchronization is normal.

[0123] It should be noted that here, the SQL statement is inserted and the first query SQL statement is used to verify whether the data synchronization function after the field value is inserted in GG synchronization is normal.

[0124] 307. If the field value inserted in the source table exists in the target table and the corresponding field name is the same, execute the preset update SQL statement to update the field value inserted in the source table;

[0125] In this embodiment, for the SQL database, the command line for updating the field is configured as a preset update SQL statement, which can be update table_name (source table name) set A (field name) = new-value (new field value). By updating the SQL statement, the field values ​​of the corresponding fields are updated, which is the action of updating the field values ​​in the source table.

[0126] 308. Execute the preset second query SQL statement to determine whether there is an updated field value in the source table in the target table and the corresponding field name is the same;

[0127] In this embodiment, when the second query SQL statement in the source data is executed, the fields after the field values ​​are reassigned will still be synchronized to the target database. Therefore, it is only necessary to query whether the fields of the corresponding target table in the target database also update the field values ​​to determine whether the GG synchronization is normal.

[0128] It should be noted that here, the update SQL statement and the second query SQL statement are used to verify whether the data synchronization function is normal after the field value is updated in GG synchronization.

[0129] 309. If the updated field value in the source table exists in the target table and the corresponding field name is the same, execute the preset delete SQL statement to delete the updated field value in the source table;

[0130] In this embodiment, for the SQL database, a command line for deleting fields is configured as a preset deletion SQL statement, which can be delete from table_name (source table name) where value (field value). By deleting the SQL statement, the corresponding fields are deleted, that is, the action of deleting the field value in the source table is performed.

[0131] 310. Execute the preset third query SQL statement to determine whether the updated field value in the source table synchronized in the target table has been deleted and whether the field name corresponding to the deleted field value is the same;

[0132] In this embodiment, when the third query SQL statement in the source data is executed, the field after the field value is deleted will still be synchronized to the target database. Therefore, it is only necessary to query whether the field values ​​of each field in the corresponding target table in the target database are also deleted to determine whether the GG synchronization is normal.

[0133] It should be noted that the SQL statement and the third query SQL statement are deleted here to verify whether the data synchronization function is normal after the field value is deleted in GG synchronization.

[0134] 311. If each record of the source table is correctly synchronized to the target table, then at the end of GG synchronization, verify whether the number of records in the source table and the target table is consistent;

[0135] 312. Output the GG synchronization verification result between the source database and the target database.

[0136] In an embodiment of the present invention, a method for verifying whether each record in the source table is correctly synchronized to the target table is introduced in detail. First, each field in the source table is assigned a value, and then the field value is inserted, updated, and deleted in turn. After GG synchronization, it is determined whether the field values ​​of the corresponding fields in the target table are inserted, updated, and deleted, and the above three synchronization functions of GG synchronization are checked to see whether they are correct, thereby realizing the second-level verification of GG synchronization.

[0137] See also Figure 4 The fourth embodiment of the database synchronization verification method in the embodiment of the present invention includes:

[0138] 401. Receive a GG synchronization request between a source database and a target database and perform GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method;

[0139] 402. Parse the GG synchronization request to obtain the owner name and table name of the source table, and obtain the owner name and table name of the target table;

[0140] 403. Verify whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table;

[0141] 404. If the table structures of the source table and the target table are defined correctly, verify whether each record of the source table is correctly synchronized to the target table;

[0142] 405. If each record of the source table is correctly synchronized to the target table, then when the GG synchronization is finished, the first number of records of the source table and the second number of records of the target table are obtained respectively, and it is determined whether the first number of records is consistent with the second number of records;

[0143] In this embodiment, for an Oracle database, select count() from COLUMN_NAME (i.e., table name) is used to execute the database statement to obtain the number of records of the fields in the source table and the target table corresponding to the table name. If the two numbers are the same, it can be determined that all fields have passed the check. Otherwise, it is determined that the synchronization of the fields of the corresponding source table has failed and cannot pass the check, and a notification message indicating that the check failed is output.

[0144] 406. When data differences are detected during GG synchronization, the checkpoint where the data differences occur is recorded and a data difference description is generated;

[0145] In this embodiment, for the verification results of the first to sixth aspects during the GG synchronization process, when data anomalies occur during the GG synchronization process, the checkpoints where the data anomalies occur are recorded and corresponding data difference descriptions are generated, such as table structure anomalies, field synchronization errors, field record number errors, etc., wherein the table structure anomalies are followed by specific data anomaly descriptions, including field value insertion anomalies, field value update anomalies, and field value deletion anomalies. The data difference description can be output as the G data synchronization verification result between the source database and the target database.

[0146] 407. Output the GG synchronization verification result between the source database and the target database.

[0147] In an embodiment of the present invention, verification of whether the number of records in the source table and the target table are consistent is introduced in detail. By respectively obtaining the first number of records in the source table and the second number of records in the target table and comparing them, it is directly possible to determine whether the two are consistent. If they are inconsistent, a data difference description needs to be generated to achieve the third-level verification of GG synchronization.

[0148] The above describes the database synchronization verification method in the embodiment of the present invention. The following describes the database synchronization verification device in the embodiment of the present invention. Figure 5 , an embodiment of the database synchronization verification device in the embodiment of the present invention includes:

[0149] The receiving module 501 is used to receive a GG synchronization request between a source database and a target database and perform GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method;

[0150] The parsing module 502 is used to parse the GG synchronization request to obtain the owner name and table name of the source table, and to obtain the owner name and table name of the target table;

[0151] A first verification module 503 is used to verify whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table;

[0152] The second verification module 504 is used to verify whether each record of the source table is correctly synchronized to the target table if the table structures of the source table and the target table are correctly defined;

[0153] The third verification module 505 is used to verify whether the number of records in the source table and the target table is consistent when the GG synchronization ends if each record in the source table is correctly synchronized to the target table;

[0154] The output module 506 is used to output the GG synchronization verification result between the source database and the target database.

[0155] In an embodiment of the present invention, after receiving a GG synchronization request, GG synchronization verification is performed; through the source table attribute name, table name and the target table owner name, table name in the GG synchronization request, it is verified whether the table structure definitions of the source table and the target table are correct; then it is verified whether each record of the source table is correctly synchronized to the target table; then it is verified whether the number of records in the source table and the target table is consistent; finally, all GG synchronization verification results of the source table and the target table are output to realize automatic detection of GG synchronized data and improve the accuracy and efficiency of detection.

[0156] See also Figure 6 Another embodiment of the database synchronization verification device in the embodiment of the present invention includes:

[0157] The receiving module 501 is used to receive a GG synchronization request between a source database and a target database and perform GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method;

[0158] The parsing module 502 is used to parse the GG synchronization request to obtain the owner name and table name of the source table, and to obtain the owner name and table name of the target table;

[0159] A first verification module 503 is used to verify whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table;

[0160] The second verification module 504 is used to verify whether each record of the source table is correctly synchronized to the target table if the table structures of the source table and the target table are correctly defined;

[0161] The third verification module 505 is used to verify whether the number of records in the source table and the target table is consistent when the GG synchronization ends if each record in the source table is correctly synchronized to the target table;

[0162] The output module 506 is used to output the GG synchronization verification result between the source database and the target database.

[0163] Specifically, the first verification module includes:

[0164] The first determination unit 5031 is used to determine whether the field type of each field in the source table and the target table is consistent and whether the field length of the target table is greater than or equal to the field length of the source table according to the owner name and table name of the source table and the owner name and table name of the target table;

[0165] A search unit 5032 is used to search whether the unique index name and each table name of the target table exist in the source table if the field type and field length of each field in the source table and the target table are correct;

[0166] The determination unit 5033 is used to determine whether the table structure definitions of the source table and the target table are correct if the unique index name and each table name of the target table exist in the source table.

[0167] Specifically, the second verification module includes:

[0168] The acquisition unit 5041 is used to acquire the field value corresponding to each field from the preset configuration table according to the field type and field length of each field in the source table if the table structure definitions of the source table and the target table are correct;

[0169] The second determination unit 5042 is used to execute the preset insert SQL statement and write the acquired field value of each field into the source table; the acquisition unit is used to execute the preset first query SQL statement to determine whether the field value inserted in the source table exists in the target table and the corresponding field name is the same;

[0170] The third determination unit 5043 is used to execute the preset update SQL statement to update the inserted field value in the source table if the field value inserted in the source table exists in the target table and the corresponding field name is the same; execute the preset second query SQL statement to determine whether the updated field value in the source table exists in the target table and the corresponding field name is the same;

[0171] The fourth judgment unit 5044 is used to execute a preset deletion SQL statement to delete the updated field value in the source table if the updated field value in the source table exists in the target table and the corresponding field name is the same; execute a preset third query SQL statement to determine whether the updated field value in the source table synchronized in the target table has been deleted and the field name corresponding to the deleted field value is the same.

[0172] Specifically, the third verification module is further used for:

[0173] If each record of the source table is correctly synchronized to the target table, when the GG synchronization is completed, the first number of records of the source table and the second number of records of the target table are obtained respectively, and it is determined whether the first number of records is consistent with the second number of records.

[0174] Specifically, the database synchronization verification device also includes:

[0175] The recording module 507 is used to record the checkpoint where the data difference occurs and generate a data difference description when a data difference is detected during the GG synchronization process.

[0176] Specifically, the source table and the target table are stored in a blockchain.

[0177] In an embodiment of the present invention, the three-layer verification of GG synchronization is introduced in detail. If the table name, primary attribute name, and field type, field length, and index name of the source table and the target table are consistent, it can be determined that the table structure definitions of the source table and the target table are correct, and the first round of verification of GG synchronization is realized; then, each field in the source table is assigned a value, and the field value is inserted, updated, and deleted in turn. After GG synchronization, it is determined whether the field values ​​of the corresponding fields in the target table are inserted, updated, and deleted, and it is verified whether the above three synchronization functions of GG synchronization are correct, so as to realize the second layer verification of GG synchronization; finally, by respectively obtaining the first number of records in the source table and the second number of records in the target table and comparing them, it is directly obtained whether the two are consistent. If they are inconsistent, a data difference description needs to be generated to realize the third layer verification of GG synchronization.

[0178] above Figure 5 and Figure 6 The database synchronization verification device in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The database synchronization verification device in the embodiment of the present invention is described in detail from the perspective of hardware processing.

[0179] Figure 7It is a structural diagram of a database synchronization verification device provided by an embodiment of the present invention. The database synchronization verification device 700 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 710 (for example, one or more processors) and a memory 720, and one or more storage media 730 (for example, one or more massive storage devices) storing application programs 733 or data 732. Among them, the memory 720 and the storage medium 730 can be short-term storage or permanent storage. The program stored in the storage medium 730 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the database synchronization verification device 700. Furthermore, the processor 710 can be configured to communicate with the storage medium 730 to execute a series of instruction operations in the storage medium 730 on the database synchronization verification device 700.

[0180] The database synchronization verification device 700 may also include one or more power supplies 740, one or more wired or wireless network interfaces 750, one or more input and output interfaces 760, and / or one or more operating systems 731, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 7 The structure of the database synchronization verification device shown does not constitute a limitation on the database synchronization verification device, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.

[0181] The present invention also provides a database synchronization verification device, which includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor executes the steps of the database synchronization verification method in the above-mentioned embodiments.

[0182] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the database synchronization verification method.

[0183] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0184] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0185] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0186] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A database synchronization verification method, characterized in that: The database synchronization verification method comprises: Receiving a GG synchronization request between a source database and a target database and performing GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method; Parse the GG synchronization request to obtain the owner name and table name of the source table, and obtain the owner name and table name of the target table; Verify whether the table structure definitions of the source and target tables are correct based on the owner name and table name of the source table and the owner name and table name of the target table. If the table structures of the source table and the target table are defined correctly, verify whether each record of the source table is correctly synchronized to the target table; If the table structures of the source table and the target table are defined correctly, verifying whether each record of the source table is correctly synchronized to the target table includes: If the table structures of the source table and the target table are correctly defined, then the field value corresponding to each field in the source table is obtained from the preset configuration table according to the field type and field length of each field in the source table; Execute the preset insert SQL statement to write the obtained field value of each field into the source table; Execute the preset first query SQL statement to determine whether the target table contains the field value inserted in the source table and the corresponding field name is the same; If the field value inserted in the source table exists in the target table and the corresponding field name is the same, the preset update SQL statement is executed to update the field value inserted in the source table; Execute the preset second query SQL statement to determine whether the target table has the updated field value in the source table and the corresponding field name is the same; If the updated field values ​​in the source table exist in the target table and the corresponding field names are the same, the preset delete SQL statement is executed to delete the updated field values ​​in the source table; Execute the preset third query SQL statement to determine whether the updated field value in the source table synchronized in the target table has been deleted and whether the field name corresponding to the deleted field value is the same; If each record of the source table is correctly synchronized to the target table, then at the end of GG synchronization, verify whether the number of records in the source table and the target table is consistent; Output the GG synchronization verification results between the source database and the target database.

2. The database synchronization verification method according to claim 1, characterized in that: The step of verifying whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table includes: According to the owner name and table name of the source table and the owner name and table name of the target table, determine whether the field type of each field in the source table and the target table is consistent and whether the field length of the target table is greater than or equal to the field length of the source table; If the field type and field length of each field in the source table and the target table are correct, check whether the unique index name and column names of the target table exist in the source table; If the unique index name and column names of the target table exist in the source table, make sure that the table structures of the source and target tables are defined correctly.

3. The database synchronization verification method according to claim 1, characterized in that: If each record of the source table is correctly synchronized to the target table, then at the end of GG synchronization, verifying whether the number of records in the source table and the target table is consistent includes: If each record of the source table is correctly synchronized to the target table, when the GG synchronization is completed, the first number of records of the source table and the second number of records of the target table are obtained respectively, and it is determined whether the first number of records is consistent with the second number of records.

4. The database synchronization verification method according to any one of claims 1 to 3, characterized in that: If each record of the source table is correctly synchronized to the target table, then at the end of GG synchronization, after verifying whether the number of records in the source table and the target table is consistent, it also includes: When data differences are detected during GG synchronization, the checkpoint where the data differences occur is recorded and a data difference description is generated.

5. The database synchronization verification method according to claim 1, characterized in that: The source table and the target table are stored in a blockchain.

6. A database synchronization verification device, characterized in that: The database synchronization verification device comprises: A receiving module, used for receiving a GG synchronization request between a source database and a target database and performing GG synchronization, wherein the GG synchronization is a log-based structured data synchronization method; A parsing module, used for parsing the GG synchronization request, obtaining the owner name and table name of the source table, and obtaining the owner name and table name of the target table; A first verification module is used to verify whether the table structure definitions of the source table and the target table are correct according to the owner name and table name of the source table and the owner name and table name of the target table; The second verification module is used to verify whether each record of the source table is correctly synchronized to the target table if the table structures of the source table and the target table are correctly defined; If the table structures of the source table and the target table are defined correctly, verifying whether each record of the source table is correctly synchronized to the target table includes: If the table structures of the source table and the target table are correctly defined, then the field value corresponding to each field in the source table is obtained from the preset configuration table according to the field type and field length of each field in the source table; Execute the preset insert SQL statement to write the obtained field value of each field into the source table; Execute the preset first query SQL statement to determine whether the target table contains the field value inserted in the source table and the corresponding field name is the same; If the field value inserted in the source table exists in the target table and the corresponding field name is the same, the preset update SQL statement is executed to update the field value inserted in the source table; Execute the preset second query SQL statement to determine whether the target table has the updated field value in the source table and the corresponding field name is the same; If the updated field values ​​in the source table exist in the target table and the corresponding field names are the same, the preset delete SQL statement is executed to delete the updated field values ​​in the source table; Execute the preset third query SQL statement to determine whether the updated field value in the source table synchronized in the target table has been deleted and whether the field name corresponding to the deleted field value is the same; The third verification module is used to verify whether the number of records in the source table and the target table is consistent when the GG synchronization is completed if each record in the source table is correctly synchronized to the target table; The output module is used to output the GG synchronization verification results between the source database and the target database.

7. A database synchronization verification device, characterized in that: The database synchronization verification device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instruction in the memory to enable the database synchronization verification device to execute the database synchronization verification method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the database synchronization verification method according to any one of claims 1 to 5 is implemented.