Database migration test method, device and equipment

Automatically comparing database table structures and data through JDBC interfaces and field mapping rules solves the low efficiency of traditional methods and enables efficient database migration testing and troubleshooting.

CN120804061APending Publication Date: 2025-10-17AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511024665.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-24
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Traditional manual verification methods are inefficient and difficult to verify data integrity during database migration of massive data. In addition, traditional database data comparison tools cannot adapt to new databases.

Method used

Load the drivers of the source and target databases through the JDBC interface, read the table list and compare the table structure and table data according to the field mapping rules, generate a visual report, support multi-threaded concurrency and paging comparison, and implement automated database migration testing.

Benefits of technology

It improves the compatibility of database types and the efficiency of data migration testing, can quickly identify migration problems, and generate visual comparison results to facilitate problem troubleshooting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120804061A_ABST
    Figure CN120804061A_ABST
Patent Text Reader

Abstract

The invention discloses a database migration test method, device and equipment, and the method comprises the steps: designing and defining a unified programming interface through a JDBC standardized interface and driver decoupling, and loading a driver of a to-be-compared source database and a driver of a migrated target database through the interface, so as to establish the connection between the source database and the target database. And for different types of databases, unified access can be realized through the interface only by developing the driver of the database, so that the compatibility of the database types is improved. In the testing process, a user configures a table list comprising a source table name and a target table name which need to be compared, the table structures of the source table and the target table are automatically read according to the table list, the table structures are compared according to the configured field mapping rule, and a table structure comparison result is obtained. In addition, the table data comparison operation of the source table and the target table can be executed according to the table list to obtain a table data comparison result, and the verification effect of the data integrity in the data migration test process is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data migration testing, and more particularly to a database migration testing method, device and equipment. BACKGROUND

[0002] In the database application migration process, the main issues involve migration of application data and adaptation of application system functions to the new database. Database migration testing includes verification of data integrity, i.e., all necessary application data and configuration data are completely and accurately migrated to the target database to avoid the occurrence of "data loss" and "dirty data" during the migration process. The traditional manual verification method has significant defects, and manual line-by-line comparison is extremely inefficient and difficult to handle massive data. Therefore, an automated database data comparison tool is needed to perform efficient and accurate data comparison.

[0003] Traditional database data comparison tools generally only support data comparison of a small number of types of databases. When a new type of database appears, the traditional database data comparison tool cannot adapt to the data comparison of the new type of database. SUMMARY

[0004] In view of the above problems, the present application is proposed to provide a database migration testing method, device and equipment to realize automatic comparison of data of various types of databases, improve the compatibility of database types, and help troubleshoot data migration problems. The specific scheme is as follows:

[0005] In a first aspect, a database migration testing method is provided, comprising:

[0006] loading the configured drivers of the source database and the migrated target database through the JDBC interface to establish a connection between the source database and the target database;

[0007] reading the table list configured by the user, the table list including the source table name and the target table name;

[0008] reading the table structure of the source table according to the source table name, and reading the table structure of the target table according to the target table name;

[0009] comparing the table structure of the source table and the table structure of the target table according to the configured field mapping rules before and after database migration to obtain a table structure comparison result;

[0010] performing a table data comparison operation of the source table and the target table according to the table list to obtain a table data comparison result.

[0011] In a possible design, in another implementation manner of the first aspect of the embodiment of the present application, the field mapping rule includes a mapping rule of any one or more attribute fields of a field type, a length, a precision, a null, and a default value.

[0012] In a possible design, in another implementation manner of the first aspect of the embodiment of the present application, the method further includes:

[0013] generating a visual table structure comparison result report based on the table structure comparison result, wherein normal and abnormal attribute fields in the table structure comparison are distinguished and marked in different forms in the table structure comparison result report.

[0014] In a possible design, in another implementation manner of the first aspect of the embodiment of the present application, according to the table list, a process of performing a table data comparison operation on the source table and the target table to obtain a table data comparison result includes:

[0015] determining whether the source table corresponding to the source table name in the table list exists in the source database, and whether the target table corresponding to the target table name exists in the target database, and recording a determination result if a data table does not exist;

[0016] if the data tables corresponding to the source table name and the target table name in the table list both exist, further determining whether the data volume of the source table and the target table after migration corresponding to the source table is consistent, and recording a determination result if the data volume is inconsistent;

[0017] if the data volume is consistent, further determining whether the data content of the source table and the target table after migration corresponding to the source table is consistent, to obtain a table data comparison result.

[0018] In a possible design, in another implementation manner of the first aspect of the embodiment of the present application, the table list further includes a sorting field, and the sorting field is a field for determining a display order of a data row.

[0019] The process of determining whether the data content of the source table and the target table after migration corresponding to the source table is consistent includes:

[0020] finding the same column name and the different column name of the source table and the target table after migration corresponding to the source table;

[0021] for the same column name, respectively reordering rows of the source table and the target table according to the sorting field, and respectively reordering columns of the source table and the target table according to a set field sorting order, to obtain reordered source table and target table;

[0022] determining whether the data content of the reordered source table and the target table is consistent.

[0023] In a possible design, in another implementation manner of the first aspect of the embodiment of the present application, after judging that the data amount of the source table and the data amount of the corresponding migrated target table are consistent, and before judging whether the data content of the source table and the corresponding migrated target table is consistent, the method further includes:

[0024] judging whether the data amount of the source table is greater than the set paging data amount, if not, performing the operation of judging whether the data content of the source table and the corresponding migrated target table is consistent in a whole table comparison manner, and if yes, paging the source table and the corresponding migrated target table respectively, and performing the operation of judging whether the data content of the source table and the corresponding migrated target table is consistent in a paging comparison manner.

[0025] In a possible design, in another implementation manner of the first aspect of the embodiment of the present application, the process of performing the operation of judging whether the data content of the source table and the corresponding migrated target table is consistent in a paging comparison manner includes:

[0026] adopting a multi-thread concurrent manner to call different threads to perform the operation of judging whether the data content of the source table and the corresponding migrated target table is consistent.

[0027] In a possible design, in another implementation manner of the first aspect of the embodiment of the present application, the method further includes:

[0028] when the table data content comparison is inconsistent, outputting the inconsistent abnormal data content in the source table and the target table.

[0029] The second aspect provides a database migration testing device, including:

[0030] a database connection unit, configured to load the drivers of the configured source database and the migrated target database through a JDBC interface, to establish a connection with the source database and the target database;

[0031] a table list reading unit, configured to read a table list configured by a user, the table list including a source table name and a target table name;

[0032] a table structure reading unit, configured to read a table structure of a source table according to the source table name, and read a table structure of a target table according to the target table name;

[0033] a table structure comparison unit, configured to compare the table structure of the source table and the table structure of the target table according to a configured field mapping rule before and after database migration, to obtain a table structure comparison result;

[0034] a table data comparison unit, configured to perform a table data comparison operation on the source table and the target table according to the table list, and obtain a table data comparison result.

[0035] In a third aspect, an electronic device is provided, including a memory and a processor.

[0036] The memory is configured to store a program.

[0037] The processor is configured to execute the program to implement the steps of the database migration test method described in any one of the preceding first aspects.

[0038] By the above technical solution, the present application uses a JDBC standardized interface and a decoupling design of a driver, defines a unified programming interface, loads the drivers of the source database and the target database after migration to be compared through the interface, and establishes a connection with the source database and the target database. For different types of databases, only the driver of the database needs to be developed to be uniformly accessed through the JDBC interface, improving the compatibility of the database types. In the test process, the user only needs to configure a table list including the source table name and the target table name to be compared, and the method of the present application can automatically read the table structures of the source table and the target table according to the table list, compare the table structures according to the configured field mapping rules, and obtain a table structure comparison result. In addition, the method can also perform a table data comparison operation on the source table and the target table according to the table list, and obtain a table data comparison result. Through the automatic comparison and analysis of the table structures and the table data, the verification effect of the data integrity in the data migration test process can be improved. BRIEF DESCRIPTION OF DRAWINGS

[0039] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included to provide a description of preferred embodiments, and are not meant to limit the present application. Moreover, the same reference numerals in different figures represent the same or similar components. In the drawings:

[0040] Figure 1 An implementation system architecture diagram of the database migration test provided by the embodiments of the present application is shown;

[0041] Figure 2 A database migration test method flow diagram provided by the embodiments of the present application is shown;

[0042] Figure 3 A function diagram of the data comparison tool provided by the present application is shown;

[0043] Figure 4 A table data comparison flow diagram provided by the embodiments of the present application is shown;

[0044] Figure 5Another schematic diagram of a table data comparison process provided in an embodiment of the present application;

[0045] Figure 6 A schematic diagram of the structure of a database migration testing device provided in an embodiment of the present application;

[0046] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0048] This application provides a database migration testing method that can be applied to Figure 1 The system architecture shown in FIG. 1 may include a terminal 100 and a server 200. The server 200 may include one or more servers ( Figure 1 (This section includes a server as an example).

[0049] The terminal 100 or the server 200 can be used alone to execute the database migration test method provided in the embodiment of the present application. In addition, the terminal 100 and the server 200 can also be used together to execute the database migration test method provided in the embodiment of the present application.

[0050] The embodiment of the present application provides a database migration test method, which is illustrated by applying the method to a computer device. The computer device can be Figure 1 The terminal 100 or the system consisting of the terminal 100 and the server 200. Figure 2 , the database migration test method specifically includes the following steps:

[0051] Step S100: Load the configured source database and the driver of the migrated target database through the JDBC interface to establish a connection with the source database and the target database.

[0052] The JDBC interface (Java Database Connectivity) is a standardized API for accessing databases developed in the Java programming language. This application develops a unified database access interface using the JDBC interface, which can mask the underlying differences between different databases.

[0053] For each type of database, the corresponding driver can be pre-configured, and the driver can be loaded through the JDBC interface to establish a connection with the corresponding database.

[0054] For the database migration test scenario, the database before migration is the source database, and the database after migration is the target database. The source database and the target database can be homogeneous databases or heterogeneous databases.

[0055] In this step, the driver of the source database and the driver of the target database are loaded through the JDBC interface, thereby establishing a connection with the source database and the target database.

[0056] Step S110, read the table list configured by the user, which includes the source table name and the target table name.

[0057] In this application, the user can configure the table list, configure the source table name in the source database, and the target table name in the target database after migration in the table list.

[0058] This application supports batch data table comparison, that is, the user can configure multiple source table name-target table name in the table list.

[0059] Step S120, read the table structure of the source table according to the source table name, and read the table structure of the target table according to the target table name.

[0060] Since the connection with the source database and the target database has been established in the foregoing steps, the source database and the target database can be accessed, and the table structure of the source table and the table structure of the target table are read according to the table list.

[0061] Step S130, according to the configured field mapping rule before and after database migration, compare the table structure of the source table and the table structure of the target table, and obtain a table structure comparison result.

[0062] The field mapping rule before and after database migration can be pre-configured in this application, and any one or more attribute fields such as field type, length, precision, null, and default value can be checked through the field mapping rule, as shown in the following table. Figure 3

[0063] Among them, the field mapping rule defines the conversion rule of different attribute fields before and after database migration, and the table structure comparison result can be obtained by checking whether the table structure of the source table and the target table conforms to the rule according to the field mapping rule.

[0064] In this embodiment, the field mapping rule of the table structure can be customized according to the cross-heterogeneous database table structure mapping relationship analysis.

[0065] ​The following Table 1 illustrates an example of field mapping rules for Oracle-Gbase database comparison.

[0066] Table 1

[0067]

[0068] Further optionally, after obtaining the table structure comparison result, a visual table structure comparison result report can be generated based on the table structure comparison result, and the normal and abnormal attribute fields in the table structure comparison result report are marked differently.

[0069] After completing the table structure comparison, a visual result report of the table structure comparison can be automatically generated. The first page of the report can be a result viewing instruction, the second page is a comparison result overview, and the following pages are single comparison result details. The abnormal attribute fields and the normal attribute fields of the table structure comparison can be marked differently in color, for example, a green marked field is a normal attribute mapping field, a yellow marked field is an abnormal attribute mapping field, and an unmarked field is a field name inconsistency field. The comparison result can be fed back to the R&D personnel for troubleshooting of database migration abnormal problems.

[0070] Step S140: performing table data comparison operation on the source table and the target table according to the table list, to obtain a table data comparison result.

[0071] The database migration test method provided in the embodiment can implement table data comparison on the basis of implementing table structure comparison, for example, Figure 3 As shown in the table data comparison operation includes, but is not limited to, whether the table exists, data volume consistency, column name (field) consistency, data consistency, and the like. Based on the table data comparison operation, a table data comparison result can be obtained.

[0072] The embodiment of the application provides a database data comparison tool, which can realize the data migration test method provided in the above embodiment, utilizes a JDBC standardized interface and a driver decoupling design, defines a unified programming interface, loads the drivers of a source database and a target database after migration to be compared through the interface, and establishes a connection with the source database and the target database. For different types of databases, only the driver of the database needs to be developed to be uniformly accessed through the JDBC interface, and the compatibility of the database type is improved. In the test process, the user only needs to configure a table list including a source table name and a target table name to be compared, and the method can automatically read the table structure of the source table and the target table according to the table list, compare the table structure according to the configured field mapping rule, and obtain a table structure comparison result. In addition, the table data comparison operation of the source table and the target table can also be performed according to the table list, and a table data comparison result is obtained. Through the automatic comparison and analysis of the table structure and the table data, the data migration problem can be excluded.

[0073] With reference to Figure 4 , a table data comparison process schematic diagram is provided.

[0074] As shown in Figure 4 , according to the table list, the table data comparison operation of the source table and the target table is performed, and the process of obtaining a table data comparison result can include the following steps:

[0075] Step S200, it is judged whether each data table in the table list exists, if not, step S230 is executed to record the comparison result, if yes, step S210 is executed.

[0076] Specifically, it is judged whether the source table corresponding to the source table name in the table list exists in the source database, and whether the target table corresponding to the target table name exists in the target database, if a data table does not exist, it is recorded that the data table of which database does not exist.

[0077] Step S210, it is judged whether the table data volume is consistent, if not, step S230 is executed to record the comparison result, if yes, step S220 is executed.

[0078] Specifically, it is judged whether the data volume of the source table and the target table after migration corresponding thereto is consistent, if not, the data volume of the source table and the target table is recorded respectively.

[0079] Step S220, it is judged whether the data content of the source table and the target table after migration corresponding thereto is consistent, and step S230 is executed to record the comparison result, so that a table data comparison result is obtained.

[0080] The table data comparison process provided by the embodiment can quickly find problems existing in the migration process by judging whether each data table in the table list exists and whether the data volume of the source table and the target table is consistent. When the data volume of the source table and the target table is consistent, it is further judged whether the data content of the two is consistent, thereby improving the data comparison efficiency.

[0081] Optionally, when the table data content is inconsistent, the inconsistent abnormal data content in the source table and the target table can be output, thereby assisting the R&D personnel to quickly troubleshoot the problem data.

[0082] In some embodiments of the present application, the table list configured by the user can further include a sorting field, which is a field for determining the display order of the data rows. On this basis, the process of judging whether the data content of the source table and the corresponding target table after migration is consistent in the above step S220 can include:

[0083] Step S1, finding the same column name and different column name of the source table and the corresponding target table after migration.

[0084] If the column names are inconsistent, the inconsistent column names between the two database data tables can be displayed in the table data comparison result.

[0085] Step S2, for the same column name, respectively reordering the rows of the source table and the target table according to the sorting field, and respectively reordering the columns of the source table and the target table according to the set field sorting order, to obtain the reordered source table and target table.

[0086] By setting the sorting field, the rows of the source table and the target table are respectively reordered according to the sorting field, and the columns of the source table and the target table are reordered according to the set field sorting order, which can facilitate the comparison of the data content of the source table and the target table in the subsequent steps.

[0087] The following provides a specific example of reordering the rows and columns of the source table and the target table with the same column name.

[0088] The following Table 2 and Table 3 respectively illustrate the source table and the target table.

[0089] Table 2

[0090]

[0091] Table 3

[0092]

[0093] The same fields (column names) in the source table and the target table are queried, for the same fields, the A field is taken as the sorting field, the source table and the target table are re-ordered in the order from small to large, and the source table and the target table are re-ordered in the order of A-E fields, and the re-ordered source table and target table are shown in Table 4 and Table 5 respectively.

[0094] Table 4

[0095]

[0096] Table 5

[0097]

[0098] S3, judging whether the data contents of the re-ordered source table and the target table are consistent.

[0099] Since the re-ordered source table and the target table are re-ordered in the order of the sorting field and the columns are re-ordered in the order of the set field, it is more convenient to compare whether the data contents of the source table and the target table are consistent.

[0100] If the data contents are inconsistent, the table data comparison result can show that the data is inconsistent, in addition, the column name (defined as an abnormal field) of the inconsistent data contents can be given, and the abnormal data file can be exported.

[0101] Referring to Figure 5 , another table data comparison process diagram is provided.

[0102] As shown in Figure 5 , the process of performing table data comparison operation of the source table and the target table according to the table list to obtain the table data comparison result can include the following steps:

[0103] Step S300, judging whether each data table in the table list exists, if not, executing step S360 to record the comparison result, if yes, executing step S310.

[0104] Specifically, it can be judged whether the source table corresponding to the source table name in the table list exists in the source database, and whether the target table corresponding to the target table name exists in the target database, if a data table does not exist, record which database the data table does not exist.

[0105] Step S310, judging whether the table data volume is consistent, if not, executing step S360 to record the comparison result, if yes, executing step S320.

[0106] Specifically, it can be judged whether the data volume of the source table and the target table corresponding to the migrated source table is consistent, if not, record the data volume of the source table and the target table respectively.

[0107] Step S320, determining whether the data amount is greater than the set paging data amount, if not, executing step S330, if yes, executing step S340.

[0108] The set paging data amount is a pre-set data threshold, when the data amount in the source table (the data amount of the source table and the target table is the same) exceeds the threshold, it indicates that the data table needs to be paged, otherwise, the data table does not need to be paged.

[0109] Step S330, determining whether the data contents of the source table and the corresponding migrated target table are consistent in the whole table comparison manner, and executing step S360 to record the comparison result.

[0110] Step S340, paging the source table and the corresponding migrated target table respectively.

[0111] Step S350, determining whether the data contents of the source table and the corresponding migrated target table are consistent in the paging comparison manner, and executing step S360 to record the comparison result, thereby obtaining the table data comparison result.

[0112] The method provided in the embodiment determines whether the data amount of the source table (the target table) exceeds the set paging data amount, when the data amount exceeds the set paging data amount, it indicates that the data amount is too large, at this time, the source table and the target table can be paged, and then the data contents of the source table and the target table can be determined whether consistent in the paging comparison manner. The paging comparison mechanism can prevent the program from being stuck due to the overflow of the local memory.

[0113] Further optionally, in the process of determining whether the data contents of the source table and the corresponding migrated target table are consistent in the paging comparison manner, different threads can be called to perform the determination operation of whether the data contents of different pages are consistent in a multi-thread concurrent manner. Through the multi-thread concurrent strategy, efficient comparison of batch data tables can be realized, and the data comparison efficiency can be improved.

[0114] In some possible implementations, the generated table data comparison result can be output in the form of a visual report, which can include the table names of the source table and the target table, the comparison result, the abnormal field, the inconsistent column name, etc., to facilitate the researchers to troubleshoot the problem data.

[0115] In summary, the database migration test method provided in the application has the following advantages:

[0116] (1) The database type compatibility is high. The database migration test data comparison tool provided in the application utilizes the standardized interface and driver decoupling design of JDBC, realizes the test migration comparison function support of mainstream database types such as Oracle, MySQL, TDSQL, Gbase, GaussDB by defining a unified programming interface, and when a new database is added, only the corresponding driver of the new database needs to be developed.

[0117] (2) The data comparison tool of the application has high data comparison efficiency. Batch data table comparison is supported, and the multi-thread concurrent mechanism is utilized to realize the rapid comparison of million-level data tables.

[0118] (3) The tool has high usability. Users can easily use the tool, and only need to prepare the data table list, set the field mapping rule, and sort the fields to start automatic table structure or table data comparison.

[0119] (4) The tool supports page comparison. The page comparison is performed for tables with a large amount of data to avoid program freezing due to memory overflow, and partial data comparison can also be selected.

[0120] (5) The tool generates comparison results with high visualization. The tool automatically generates table structure and table data comparison results with high visualization, which can quickly locate the problem table, problem field attribute, and problem data.

[0121] The database migration test device provided in the embodiments of the application is described below. The database migration test device described below can be correspondingly referred to the database migration test method described above.

[0122] Referring to Figure 6 , Figure 6 is a structural schematic diagram of a database migration test device disclosed in the embodiments of the application.

[0123] As Figure 6 shown, the device can include:

[0124] The database connection unit 11 is configured to load the drivers of the source database and the target database after migration configured through the JDBC interface, to establish a connection between the source database and the target database.

[0125] The table list reading unit 12 is configured to read the table list configured by the user, and the table list includes the source table name and the target table name.

[0126] The table structure reading unit 13 is configured to read the table structure of the source table according to the source table name, and read the table structure of the target table according to the target table name.

[0127] The table structure comparison unit 14 is configured to compare the table structure of the source table and the table structure of the target table according to the field mapping rule before and after the database migration, and obtain a table structure comparison result.

[0128] The table data comparison unit 15 is configured to perform a table data comparison operation on the source table and the target table according to the table list, and obtain a table data comparison result.

[0129] In a possible implementation, the field mapping rule includes a mapping rule of any one or more attribute fields of a field type, a length, a precision, a null, and a default value.

[0130] In a possible implementation, the device further includes:

[0131] The first report generation unit is configured to generate a visual table structure comparison result report based on the table structure comparison result, and different forms are used to distinguish and mark normal and abnormal attribute fields in the table structure comparison result report.

[0132] In a possible implementation, the table data comparison unit performs a table data comparison operation on the source table and the target table according to the table list, and obtains a table data comparison result, including:

[0133] It is judged whether the source table corresponding to the source table name in the table list exists in the source database, and whether the target table corresponding to the target table name exists in the target database, and if there is a data table that does not exist, a judgment result is recorded.

[0134] If the data tables corresponding to the source table name and the target table name in the table list exist, it is further judged whether the data volume of the source table and the target table corresponding to the source table after migration is consistent, and if not, a judgment result is recorded.

[0135] If the data volume is consistent, it is further judged whether the data content of the source table and the target table corresponding to the source table after migration is consistent, and a table data comparison result is obtained.

[0136] In a possible implementation, the table list further includes a sorting field, and the sorting field is a field for determining a display order of data rows; the table data comparison unit judges whether the data content of the source table and the target table corresponding to the source table after migration is consistent, including:

[0137] The same column name and the different column name of the source table and the target table corresponding to the source table after migration are found.

[0138] For the same column name, the source table and the target table are respectively reordered according to the sorting field, and the source table and the target table are respectively reordered according to the set field sorting order, to obtain reordered source table and target table;

[0139] It is judged whether the data contents of the reordered source table and the target table are consistent.

[0140] In a possible implementation, the table data comparison unit, after judging that the data amounts of the source table and the corresponding migrated target table are consistent, and before judging whether the data contents of the source table and the corresponding migrated target table are consistent, is further configured to:

[0141] If not, the operation of judging whether the data contents of the source table and the corresponding migrated target table are consistent is performed in a whole-table comparison manner; if yes, the source table and the corresponding migrated target table are respectively paginated, and the operation of judging whether the data contents of the source table and the corresponding migrated target table are consistent is performed in a page-by-page comparison manner.

[0142] In a possible implementation, the table data comparison unit performs the operation of judging whether the data contents of the source table and the corresponding migrated target table are consistent in a page-by-page comparison manner, including:

[0143] In a page-by-page comparison manner, different threads are called to perform the operation of judging whether the data contents of the source table and the corresponding migrated target table are consistent.

[0144] In a possible implementation, the apparatus further includes:

[0145] An abnormal data exporting unit is configured to output abnormal data contents inconsistent between the source table and the target table when the table data contents are inconsistent.

[0146] An electronic device is provided in the embodiments of the present application. Figure 7 As shown in FIG. 1, a structural schematic diagram of an electronic device suitable for implementing the electronic device in the embodiments of the present application is shown. The electronic device in the embodiments of the present application can include, but is not limited to, a fixed terminal such as a mobile phone, a tablet computer, a desktop computer, and the like. Figure 7 The electronic device shown in FIG. 1 is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present application.

[0147] As shown in FIG. 1, a structural schematic diagram of an electronic device suitable for implementing the electronic device in the embodiments of the present application is shown. The electronic device in the embodiments of the present application can include, but is not limited to, a fixed terminal such as a mobile phone, a tablet computer, a desktop computer, and the like. Figure 7As shown, the electronic device can include a processing device (e.g., a central processor, a graphics processor, etc.) 1 that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 2 or programs loaded from a storage device 8 into a random access memory (RAM) 3 to implement the database migration test method of the foregoing embodiments of the present application. In a state where the electronic device is powered on, various programs and data required for operation of the electronic device are also stored in the RAM 3. The processing device 1, the ROM 2, and the RAM 3 are connected to each other through a bus 4. An input / output (I / O) interface 5 is also connected to the bus 4.

[0148] Generally, the following devices can be connected to the I / O interface 5: input devices 6 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 7 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 8 including, for example, a memory card, a hard disk, etc.; and communication devices 9. The communication devices 9 can allow the electronic device to communicate wirelessly or wired with other devices to exchange data. Although Figure 7 The electronic device with various devices is shown, but it should be understood that it is not required to implement or have all of the illustrated devices. More or less devices can alternatively be implemented or included.

[0149] The embodiments of the present application also provide a computer program product including computer readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the database migration test methods provided by the embodiments of the present application.

[0150] The embodiments of the present application also provide a computer readable storage medium carrying one or more computer programs, which, when executed by an electronic device, can cause the electronic device to implement any of the database migration test methods provided by the embodiments of the present application.

[0151] It should be further noted that the device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., they can be located in one place, or distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments. In addition, the connection relationship between the modules in the device embodiments provided by the present application indicates that there is a communication connection between them, which can be implemented as one or more communication buses or signal lines.

[0152] Those skilled in the art can clearly understand, through the description of the foregoing embodiments, that the present application can be implemented by means of software and the necessary universal hardware, and of course can also be implemented by means of special hardware including special integrated circuits, special CPUs, special memories, special components, etc. Generally, functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can be various, such as analog circuits, digital circuits, or special circuits. However, for the present application, software program implementation is a better embodiment. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., including a plurality of instructions to make a computer device (which can be a personal computer, training device, or network device, etc.) execute the methods described in various embodiments of the present application.

[0153] In the above embodiments, all or part can be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, it can be implemented in the form of a computer program product in whole or in part.

[0154] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another, for example, the computer instructions can be transferred from one website, computer, training device or data center to another through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. integrated with one or more available media. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)), etc.

[0155] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The embodiments can be combined as needed, and the same or similar parts refer to each other.

Claims

1. A database migration testing method, characterized in that: include: Load the configured source database and the driver of the migrated target database through the JDBC interface to establish a connection with the source database and the target database; Read the table list configured by the user, which includes the source table name and the target table name; Reading the table structure of the source table according to the table name of the source table, and reading the table structure of the target table according to the table name of the target table; Comparing the table structure of the source table and the table structure of the target table according to the configured field mapping rules before and after database migration to obtain a table structure comparison result; According to the table list, a table data comparison operation is performed on the source table and the target table to obtain a table data comparison result.

2. The method according to claim 1, characterized in that The field mapping rules include mapping rules for any one or more attribute fields of field type, length, precision, null, and default value.

3. The method according to claim 1, characterized in that Also includes: A visual table structure comparison result report is generated based on the table structure comparison result. In the table structure comparison result report, attribute fields that are normal and abnormal in the table structure comparison are distinguished and marked in different forms.

4. The method according to claim 1, wherein The process of performing a table data comparison operation on the source table and the target table according to the table list and obtaining the table data comparison result includes: Determine whether the source table corresponding to the source table name in the table list exists in the source database, and whether the target table corresponding to the target table name exists in the target database. If any table does not exist, record the determination result. If the data tables corresponding to the source table name and the target table name in the table list both exist, further determine whether the data volume of the source table and its corresponding migrated target table is consistent. If not, record the determination result. If the data amounts are consistent, it is further determined whether the data contents of the source table and its corresponding migrated target table are consistent, and a table data comparison result is obtained.

5. The method according to claim 4, characterized in that The table list also includes a sort field, which is a field that determines the display order of data rows; The process of determining whether the data contents of the source table and the corresponding migrated target table are consistent includes: Find the same column names and different column names between the source table and the corresponding target table after migration; For identical column names, reordering the source table and the target table by rows according to the sorting fields, and reordering the source table and the target table by columns according to the set field sorting order, to obtain reordered source and target tables; Determine whether the data contents of the reordered source table and the target table are consistent.

6. The method according to claim 4, characterized in that After determining whether the data amounts of the source table and the corresponding target table after migration are consistent, and before determining whether the data contents of the source table and the corresponding target table after migration are consistent, the method further includes: Determine whether the data volume of the source table is greater than the set paging data volume. If not, perform an operation to determine whether the data contents of the source table and its corresponding target table after migration are consistent in accordance with the whole table comparison method. If so, paginate the source table and its corresponding target table after migration respectively, and perform an operation to determine whether the data contents of the source table and its corresponding target table after migration are consistent in accordance with the paging comparison method.

7. The method according to claim 6, characterized in that The process of performing an operation of determining whether the data contents of the source table and the corresponding migrated target table are consistent in a page comparison manner includes: In a multi-threaded concurrent manner, different threads are called to execute an operation on different pages to determine whether the data contents of the source table and the corresponding target table after migration are consistent.

8. The method according to claim 4, characterized in that Also includes: When the table data contents are inconsistent, the inconsistent abnormal data contents of the source table and the target table are output.

9. A database migration testing device, characterized in that: include: A database connection unit, configured to load the drivers of the configured source database and the migrated target database through a JDBC interface to establish connections with the source database and the target database; A table list reading unit, configured to read a table list configured by a user, wherein the table list includes a source table name and a target table name; A table structure reading unit, configured to read the table structure of a source table according to the table name of the source table, and to read the table structure of a target table according to the table name of the target table; A table structure comparison unit is used to compare the table structure of the source table and the table structure of the target table according to the configured field mapping rules before and after database migration to obtain a table structure comparison result; The table data comparison unit is used to perform a table data comparison operation on the source table and the target table according to the table list to obtain a table data comparison result.

10. An electronic device, characterized in that: include: memory and processor; The memory is used to store programs; The processor is configured to execute the program to implement each step of the database migration testing method according to any one of claims 1 to 8.