Heterogeneous database object migration method and device, electronic equipment and storage medium

By using preset conversion rules in heterogeneous database object migration, DDL statements of source-side database objects are converted into syntax supported by target-side databases, the problems of low migration efficiency and inability to guarantee accuracy in the existing technology are solved, and efficient and accurate data migration is achieved.

CN119883207APending Publication Date: 2025-04-25JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411952870.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In the prior art, heterogeneous database object migration efficiency is inefficient and the accuracy cannot be guaranteed, especially when manually modifying and adapting objects.

Method used

By determining the object to be migrated in the source database, obtaining its original DDL statement, and using preset conversion rules to convert the original DDL statement to the target DDL statement based on the object type, source database type and target database type, the original DDL statement is converted into the target DDL statement, and finally migrating the target DDL statement to the target database and executing.

Benefits of technology

Improve the efficiency and accuracy of heterogeneous database object migration, ensure the consistency of data migration, and avoid the inefficiency and inaccuracy of manual modification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883207A_ABST
    Figure CN119883207A_ABST
Patent Text Reader

Abstract

The invention relates to a heterogeneous database object migration method and device, electronic equipment and a storage medium. According to the scheme provided by the invention, an original DDL statement of a to-be-migrated object is obtained by determining the to-be-migrated object in a source end database, and the to-be-migrated object is migrated based on the type of the to-be-migrated object, the type of the source end database and the type of a target database; and converting the original DDL statement into a target DDL statement through a corresponding preset conversion rule, migrating the target DDL statement to the target database and executing the target DDL statement, so that the target database creates the to-be-migrated object to complete migration. Compared with a scheme of manually modifying and adapting the object, the scheme provided by the invention can convert the object into the grammar format supported by the target end database through the specific conversion rule according to the difference between grammar of different types of database objects in the migration process of different types of databases, the conversion efficiency and accuracy are high, and the method and the device are easy to implement. The heterogeneous database object migration efficiency is improved, and the data consistency is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of heterogeneous database object migration, and in particular to a heterogeneous database object migration method, device, electronic device and storage medium. Background Art

[0002] In order to meet the needs of infrastructure upgrade, architecture optimization, cross-platform deployment, data security and disaster recovery, it is necessary to migrate objects in the database from one database to another. Since data migration often involves updating the database structure, that is, migrating objects in the source database to a target database with a different architecture, due to the syntax incompatibility between heterogeneous databases, it is inevitable to modify the syntax of the source database objects to the syntax supported by the target database, that is, convert the objects according to the type of the target database during the migration process.

[0003] In the existing related technologies, the DDL (Data Definition Language) statements of objects are often modified and adapted manually, which is inefficient, time-consuming and labor-intensive. In addition, the manual modification and adaptation methods are limited by personal experience and accuracy, resulting in the inability to guarantee the accuracy of object conversion. In order to solve the above problems, a solution that can quickly and accurately migrate heterogeneous database objects is urgently needed. Summary of the invention

[0004] The present application provides a heterogeneous database object migration method, device, electronic device and storage medium to improve the query performance of the database.

[0005] In a first aspect, the present application provides a heterogeneous database object migration method, the method comprising:

[0006] Determine the objects to be migrated in the source database;

[0007] Obtaining the original DDL statement of the object to be migrated;

[0008] Based on the type of the object to be migrated, the type of the source database, and the type of the target database, converting the original DDL statement into a target DDL statement through a corresponding preset conversion rule;

[0009] The target DDL statement is migrated to the target database and executed, so that the target database creates the object to be migrated and completes the migration.

[0010] In a second aspect, the present application provides a heterogeneous database object migration device, the device comprising:

[0011] An object determination module is used to determine the objects to be migrated in the source database;

[0012] A statement collection module, used to obtain the original DDL statement of the object to be migrated;

[0013] An object conversion module, configured to convert the original DDL statement into a target DDL statement according to a corresponding preset conversion rule based on the type of the object to be migrated, the type of the source database, and the type of the target database;

[0014] The object migration module is used to migrate the target DDL statement to the target database and execute it, so that the target database creates the object to be migrated and completes the migration.

[0015] In a third aspect, the present application provides an electronic device comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to execute a heterogeneous database object migration method described in the first aspect above.

[0016] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the heterogeneous database object migration method described in the first aspect of the present application.

[0017] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the heterogeneous database object migration method provided by the embodiment of the present application determines the object to be migrated in the source database, obtains the original DDL statement of the object to be migrated, converts the original DDL statement into the target DDL statement based on the type of the object to be migrated, the type of the source database and the type of the target database through the corresponding preset conversion rules, migrates the target DDL statement to the target database and executes it, so that the target database creates the object to be migrated and completes the migration. Compared with the problems of low efficiency and lack of accuracy in the prior art of manually modifying and adapting objects, the solution provided by the present application can convert objects into the grammatical format supported by the target database through specific conversion rules in the process of migrating different types of databases, targeting the differences between the syntax of different types of database objects, with high conversion efficiency and accuracy, thus improving the efficiency of heterogeneous database object migration and ensuring the consistency of data migration. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0020] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0021] Figure 1 A schematic diagram of a flow chart of a heterogeneous database object migration method provided by an embodiment of the present application;

[0022] Figure 2 A schematic diagram of a flow chart of a heterogeneous database object migration method provided in another embodiment of the present application;

[0023] Figure 3 A schematic diagram of the structure of a heterogeneous database object migration device provided in an embodiment of the present application;

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

[0025] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0026] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0027] In order to solve the problems of low efficiency and lack of accuracy in manually modifying and adapting objects when migrating heterogeneous database objects in the prior art, the present application provides a heterogeneous database object migration method, which can convert objects into a grammatical format supported by the target database through specific conversion rules based on the differences between the syntax of different types of database objects.

[0028] Figure 1 A heterogeneous database object migration method provided in the embodiment of the present application is referred to Figure 1 , a heterogeneous database object migration method provided by the present application includes:

[0029] S1: Determine the objects to be migrated in the source database.

[0030] Specifically, the source database is the database that needs to initiate data migration. For example, when responding to needs such as infrastructure upgrades, architecture optimization, cross-platform deployment, data security, and disaster recovery, it is necessary to migrate objects in database A from database A to database B, where database A is the source database and database B is the target database.

[0031] In a database, there are usually many types of objects, such as tables, indexes, functions, and stored procedures. In a feasible embodiment of the present application, the objects in the database are divided into basic objects and advanced objects. The basic objects include but are not limited to at least one of tables, indexes, sequences, and synonyms, and the advanced objects include but are not limited to at least one of stored procedures, functions, packages, and triggers.

[0032] In a feasible embodiment of the present application, a user can create an object migration task in the system by constructing a whitelist, and select a required object range to be put into the whitelist. The objects in the whitelist are the objects to be migrated.

[0033] S2: Obtain the original DDL statement of the object to be migrated.

[0034] DDL (Data Definition Language) statements are SQL statements used to define and manage database structures. The main function of DDL statements is to create, modify, and delete database objects, such as tables, views, indexes, stored procedures, etc. Specifically, the original DDL statements of the object to be migrated include all historical DDL statements corresponding to the object to be migrated, sorted in the order of execution. For example, assuming that a certain object to be migrated is created, modified for the first time, and modified for the second time in the source database, the historical DDL statements corresponding to the object to be migrated include the DDL statements corresponding to the creation, the DDL statements corresponding to the first modification, and the DDL statements corresponding to the second modification. The original DDL statements of the object to be migrated include the DDL statements corresponding to the creation, the DDL statements corresponding to the first modification, and the DDL statements corresponding to the second modification, sorted in the order of execution.

[0035] S3: Based on the type of the object to be migrated, the type of the source database, and the type of the target database, the original DDL statement is converted into a target DDL statement through corresponding preset conversion rules.

[0036] The target DDL statements include all DDL statements converted from historical DDL statements, and the target DDL statements are sorted in the order of conversion. For example, assuming that the historical DDL statements of a certain object to be migrated include statement A when it was created, statement B corresponding to the first modification, and statement C when it was modified for the second time, then the target DDL statements include statement A', statement B', and statement C' after the three historical DDL statements are converted, and are sorted in the order of statement A', statement B', and statement C', so that when the target database executes the target DDL statements, it can be restored according to the complete DDL statement operation process of the object to be migrated to ensure the accuracy and consistency of the data.

[0037] In a feasible embodiment of the present application, different conversion schemes are respectively used according to the types of objects to be migrated:

[0038] In the case where the object to be migrated is a base object, based on the type of the source database, the type of the target database and the preset general conversion rules, the original DDL statements of the base object are sequentially converted into target DDL statements supported by the target database. It should be understood that in a feasible embodiment of the present application, the general conversion rules are default general conversion rules stored in the system, including but not limited to data type conversion rules between different database types, table conversion rules, sequence conversion rules, index conversion rules, synonym conversion rules, etc.

[0039] In the existing related technologies, there is usually a lack of corresponding conversion schemes for high-level objects in the database, such as stored procedures, functions, packages, and triggers. In some specific fields, such as the financial field, these high-level objects are used frequently, so the migration adaptation of high-level objects is very important. To this end, in the scheme provided by the present application, when the object to be migrated is a high-level object, based on the type of the source database, the type of the target database, and the preset high-level object conversion rules, the original DDL statements of the high-level objects are sequentially converted into target DDL statements supported by the target database. In a feasible embodiment of the present application, the high-level object conversion rules are user-defined conversion rules, including keyword conversion rules and regular expression conversion rules. Through the keyword conversion rules, the keywords matched in the DDL creation statement of the high-level object can be converted into the required keywords; through the regular expression conversion rules, the content that conforms to the regular expression in the DDL creation statement of the high-level object can be batch converted into the expected content. It should be understood that the present application does not limit the specific content of the high-level object conversion rules, which can be flexibly set by users such as database administrators according to the architecture of the source database and the target database, the supported data types, the type of data to be converted, etc.

[0040] S4: Migrate the target DDL statement to the target database and execute it, so that the target database creates the object to be migrated and completes the migration.

[0041] Specifically, after the target DDL statement is converted, the target DDL statement is migrated to the target database, and the target database executes the target DDL statement, restores the entire DDL statement operation process of the object to be migrated, and completes the creation of the object to be migrated. Similarly, taking the above-mentioned object to be migrated as an example, assuming that the historical DDL statement of the object to be migrated includes the A statement at the time of creation, the B statement corresponding to the first modification, and the C statement at the second modification, then the target DDL statement includes the A' statement, B' statement, and C' statement after the conversion of these three historical DDL statements, and is sorted in the order of A' statement, B' statement, and C' statement. When the target database executes the target DDL statement, it executes it in the order of A' statement, B' statement, and C' statement, and performs the creation, the first modification, and the second modification of the object to be migrated in the target database, respectively, to complete the migration of the object to be migrated.

[0042] like Figure 2 As shown, in a feasible embodiment of the present application, in order to avoid the problem of data inconsistency caused by the target database being unable to synchronize the changes in time due to the changes of the basic objects in the source database during the object migration process, after the target DDL statement is migrated to the target database and executed, it also includes:

[0043] In the case of changes to the basic objects in the source database, the latest DDL statement corresponding to the basic object is obtained, the latest DDL statement is converted into a target DDL statement supported by the target database, and then the target DDL statement is migrated to the target database and executed, so that the target database synchronizes the changes of the basic object. For example, during the process of executing the target DDL statement of a basic object in the target database, the basic object is modified in the source database, then the DDL statement corresponding to the modification is captured, and the DDL statement is converted into a target DDL statement supported by the target database and then handed over to the target database for execution, so that the basic object in the target database is also modified in the same way, thereby ensuring data consistency.

[0044] Due to the possible problems of insufficient adaptability of the conversion rules and failure of the target database to execute the target DDL statement, in a feasible embodiment of the present application, Figure 2 As shown, after the target DDL statement is migrated to the target database and executed, it also includes: monitoring the execution of the target DDL statement in the target database, summarizing the target DDL statements that failed to execute, and building a list of DDL statements to be modified. Through this solution, users can easily modify the DDL statements that failed to execute, which improves the efficiency of error troubleshooting. The modified DDL statements are put back into the target database for execution to avoid inconsistency between the data in the target database and the source database.

[0045] In order to intuitively display the DDL statements before and after the conversion, so that the user can intuitively see the differences between the DDL statements before and after the conversion, so as to make error corrections and adjustments, in a feasible embodiment of the present application, after the original DDL statement is converted into a target DDL statement by the corresponding preset conversion rule, it also includes: simultaneously displaying the original DDL statement and the corresponding target DDL statement, and marking the difference between the original DDL statement and the target DDL statement. Specifically, for each historical DDL statement in the original DDL statement, it is compared and displayed with the corresponding DDL statement after conversion in the target DDL statement, so that the user can make error corrections and adjustments.

[0046] The technical solution provided by the present application determines the object to be migrated in the source database, obtains the original DDL statement of the object to be migrated, and based on the type of the object to be migrated, the type of the source database and the type of the target database, converts the original DDL statement into the target DDL statement through the corresponding preset conversion rules, migrates the target DDL statement to the target database and executes it, so that the target database creates the object to be migrated and completes the migration. Compared with the problems of low efficiency, unguaranteed accuracy and lack of advanced object conversion solutions in the prior art through manual modification and adaptation of objects, the solution provided by the present application can convert basic objects and advanced objects into the syntax format supported by the target database through specific conversion rules in the process of migrating different types of databases, targeting the differences between the syntax of different types of database objects, with high conversion efficiency and accuracy, improving the efficiency of heterogeneous database object migration and ensuring the consistency of data migration.

[0047] Corresponding to the above method embodiment, the present application also provides a heterogeneous database object migration device, referring to Figure 3 The present application provides a heterogeneous database object migration device including: an object determination module 301 , a statement collection module 302 , an object conversion module 303 and an object migration module 304 .

[0048] The object determination module 301 is used to determine the objects to be migrated in the source database.

[0049] The statement collection module 302 is used to obtain the original DDL statement of the object to be migrated.

[0050] The object conversion module 303 is used to convert the original DDL statement into the target DDL statement according to the type of the object to be migrated, the type of the source database and the type of the target database through the corresponding preset conversion rules.

[0051] The object migration module 304 is used to migrate the target DDL statement to the target database and execute it, so that the target database creates the object to be migrated and completes the migration.

[0052] In order to avoid the problem of data inconsistency caused by the target database being unable to synchronize the changes in time due to changes in the basic objects in the source database during the object migration process, in a feasible embodiment of the present application, the heterogeneous database object migration device also includes an object update module, which is used to obtain the latest DDL statement corresponding to the basic object when the basic object in the source database is changed, convert the latest DDL statement into a target DDL statement supported by the target database, and then migrate the target DDL statement to the target database and execute it, so that the target database synchronizes the changes of the basic object.

[0053] Due to the possible problems of insufficient adaptability of conversion rules and unsuccessful execution of target DDL statements by the target database, in a feasible embodiment of the present application, the heterogeneous database object migration device also includes an execution monitoring module for monitoring the execution of target DDL statements in the target database, summarizing target DDL statements that failed to execute, and building a list of DDL statements to be modified. Through this solution, users can easily modify DDL statements that failed to execute, thereby improving the efficiency of error troubleshooting. The modified DDL statements are put back into the target database for execution to avoid inconsistency between the data in the target database and the source database.

[0054] In order to intuitively display the DDL statements before and after the conversion, so that the user can intuitively see the differences between the DDL statements before and after the conversion, so as to make error corrections and adjustments, in a feasible embodiment of the present application, the heterogeneous database object migration device also includes a comparison display module, which is used to simultaneously display the original DDL statement and the corresponding target DDL statement, and mark the difference between the original DDL statement and the target DDL statement. Specifically, for each historical DDL statement in the original DDL statement, it is compared and displayed with the corresponding DDL statement after conversion in the target DDL statement, so that the user can make error corrections and adjustments.

[0055] like Figure 4 As shown, an embodiment of the present application provides an electronic device, including a processor 411, a communication interface 412, a memory 413 and a communication bus 414, wherein the processor 411, the communication interface 412, and the memory 413 communicate with each other through the communication bus 414.

[0056] The memory 413 is used to store computer programs.

[0057] In one embodiment of the present application, the processor 411 is used to implement the heterogeneous database object migration method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 413, including:

[0058] Determine the objects to be migrated in the source database;

[0059] Get the original DDL statement of the object to be migrated;

[0060] Based on the type of the object to be migrated, the type of the source database, and the type of the target database, the original DDL statement is converted into the target DDL statement through the corresponding preset conversion rules;

[0061] Migrate the target DDL statements to the target database and execute them so that the target database can create the objects to be migrated and complete the migration.

[0062] The embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the heterogeneous database object migration method provided in any of the aforementioned method embodiments are implemented.

[0063] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0064] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0065] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0066] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A heterogeneous database object migration method, characterized in that: include: Determine the objects to be migrated in the source database; Obtaining the original DDL statement of the object to be migrated; Based on the type of the object to be migrated, the type of the source database, and the type of the target database, converting the original DDL statement into a target DDL statement through a corresponding preset conversion rule; The target DDL statement is migrated to the target database and executed, so that the target database creates the object to be migrated and completes the migration.

2. The heterogeneous database object migration method according to claim 1, characterized in that: The objects to be migrated include basic objects and advanced objects; the basic objects include at least one of a table, an index, a sequence, and a synonym, and the advanced objects include at least one of a stored procedure, a function, a package, and a trigger.

3. The heterogeneous database object migration method according to claim 2, characterized in that: The original DDL statements include all historical DDL statements corresponding to the object to be migrated, which are sorted in the order of execution; the target DDL statements include all DDL statements converted from the historical DDL statements in sequence, and the target DDL statements are sorted in the order of conversion.

4. The heterogeneous database object migration method according to claim 3, characterized in that: Based on the type of the object to be migrated, the type of the source database, and the type of the target database, the original DDL statement is converted into a target DDL statement by using a corresponding preset conversion rule, including: In the case where the object to be migrated is the basic object, based on the type of the source database, the type of the target database and a preset general conversion rule, the original DDL statements of the basic object are sequentially converted into the target DDL statements supported by the target database; In the case where the object to be migrated is the high-level object, based on the type of the source database, the type of the target database and preset high-level object conversion rules, the original DDL statements of the high-level object are sequentially converted into the target DDL statements supported by the target database.

5. The heterogeneous database object migration method according to claim 3, characterized in that: After migrating the target DDL statement to the target database and executing it, the method further includes: When the basic object in the source database changes, the latest DDL statement corresponding to the basic object is obtained, the latest DDL statement is converted into the target DDL statement supported by the target database, and then the target DDL statement is migrated to the target database and executed, so that the target database synchronizes the changes of the basic object.

6. The heterogeneous database object migration method according to claim 3, characterized in that: After migrating the target DDL statement to the target database and executing it, the method further includes: The target DDL statements that failed to execute are summarized, and a list of DDL statements to be modified is constructed.

7. The heterogeneous database object migration method according to any one of claims 1 to 6, characterized in that: After the original DDL statement is converted into a target DDL statement by using a corresponding preset conversion rule, the method further includes: The original DDL statement and the corresponding target DDL statement are displayed simultaneously, and the difference between the original DDL statement and the target DDL statement is marked.

8. A heterogeneous database object migration device, characterized in that: The device comprises: An object determination module is used to determine the objects to be migrated in the source database; A statement collection module, used to obtain the original DDL statement of the object to be migrated; An object conversion module, configured to convert the original DDL statement into a target DDL statement according to a corresponding preset conversion rule based on the type of the object to be migrated, the type of the source database, and the type of the target database; The object migration module is used to migrate the target DDL statement to the target database and execute it, so that the target database creates the object to be migrated and completes the migration.

9. An electronic device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to implement the heterogeneous database object migration method according to any one of claims 1 to 7.

10. A computer storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to execute the heterogeneous database object migration method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Cross-type database migration method and device and computer equipment

    CN120743873A