Method for migrating data of heterogeneous databases

By parsing the collection packets of heterogeneous databases and transforming them using a rule engine, the problems of long migration time and high error rate in database migration are solved, achieving an efficient and accurate data migration process.

CN120295998BActive Publication Date: 2025-12-26NO 15 INST OF CHINA ELECTRONICS TECH GRP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510773359.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-11
Publication Date
2025-12-26
Estimated Expiration
2045-06-11

AI Technical Summary

Technical Problem

During the data migration process of multi-brand and multi-version databases, there are problems such as long migration time and inaccurate data. This is mainly due to inconsistencies in database structure, type and table relationships, which leads to a high migration error rate.

Method used

By acquiring collection packages from different source databases, parsing metadata, and performing lexical and syntactic analysis, unstructured text is transformed into structured syntax tree objects. Normalization mapping is then performed to form a unified syntax tree for the heterogeneous source databases. The rule engine is then invoked to perform transformation and rewriting rules, and the target syntax tree object is converted into a target database object script.

Benefits of technology

It enables automated migration of data from heterogeneous databases, improving migration efficiency and accuracy while reducing migration error rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120295998B_ABST
    Figure CN120295998B_ABST
Patent Text Reader

Abstract

The isomer database data migration method relates to the technical field of data migration, and automatically judges the source database type by analyzing the meta information in the source database collection package. Then, the SQL of the source database is subjected to lexical and syntactic analysis to form a syntax tree object of the source database. The syntax tree object of the source database and the target database syntax tree object are subjected to object migration and conversion to complete the mapping of the syntax tree object. The target syntax tree object is converted into a target database object script through rule conversion and rewriting conditions, and automatic data migration is realized.
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, and particularly relates to a heterogeneous database data migration method. BACKGROUND

[0002] When data migration is performed on multi-brand multi-version databases, there are problems such as long migration time and inaccurate data, and the main reason is that the database structures, types and table relationships are inconsistent, and the data cannot be used because it does not meet the current database constraints, resulting in data that cannot be migrated and a high migration error rate. SUMMARY

[0003] The main purpose of the present application is to provide a heterogeneous database data migration method to solve the problems in the related art.

[0004] In order to achieve the above purpose, according to the first aspect of the present application, a heterogeneous database data migration method is provided, which comprises obtaining a collection package of objects to be migrated in different source databases, and parsing the collection package to obtain meta information; based on the meta information, the objects to be migrated in each of the different source databases are parsed in terms of morphology and syntax to convert each of the objects to be migrated from unstructured text to a structured syntax tree object; each structured syntax tree object is normalized and mapped to form a unified syntax tree of the heterogeneous source database; the syntax tree object of the heterogeneous source database and the target syntax tree object of the target database are migrated and converted to complete the mapping of the syntax tree object; a rule engine is called to convert the mapped target syntax tree object into the target database object script using conversion rules and rewriting rules, wherein the script is executed to migrate the objects to be migrated in different source databases to the target database.

[0005] Optionally, based on the meta information, each of the objects to be migrated is parsed in terms of morphology and syntax to convert each of the objects to be migrated from unstructured text to a structured syntax tree object, which comprises determining the source database type corresponding to the object to be migrated based on the meta information; based on the source database type, matching the morphological and syntactic parsing method for the object to be migrated from the preset morphological and syntactic library; the object to be migrated is parsed in terms of morphology and syntax by the matched morphological and syntactic parsing method; and the characteristic morphology and syntax are marked.

[0006] Optionally, each structured syntax tree object is normalized and mapped to form a unified syntax tree object of the heterogeneous source database, which comprises normalizing and mapping each structured syntax tree object based on a predefined unified syntax rule structure covering multiple databases to form a unified structured representation of the syntax tree object of the heterogeneous source database, wherein the characteristic syntax is supplemented in the normalization process.

[0007] Optionally, the rule engine converts the objects in the mapped target syntax tree into the target database object script by using conversion rules and rewriting rules, including: determining an adaptation layer based on the syntax tree objects of the heterogeneous source database to be converted and the target syntax tree objects; loading source-target conversion rules between the syntax tree objects of the heterogeneous source database and the target syntax tree objects in the adaptation layer, and performing database rule conversion according to the source-target conversion rules; and after the rule conversion is completed, loading a source-target sentence rewriting mode between the syntax tree objects of the heterogeneous source database and the target syntax tree objects to perform sentence rewriting, to obtain the script.

[0008] Optionally, the method further includes: calling a semantic analysis service to perform syntax checking on the script; if the checking is successful, executing the script, otherwise calling the source-target sentence rewriting mode to perform rewriting to complete sentence correction.

[0009] Optionally, before the rule engine is called, the conversion rules are predefined, wherein the defined conversion rules include: replacing Cursor rules, Open rules, Case When rules and For rules of different source databases according to a description mode of the target database.

[0010] Optionally, before the rule engine is called, the rewriting rules are predefined: defining a pipeline rule rewriting mode based on different types of target databases and whether the target database has a pipeline mechanism.

[0011] Optionally, the predefined rewriting rules further include: defining a characteristic syntax rule rewriting rule for a specified characteristic syntax of different types of target databases.

[0012] According to a second aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for causing a computer to execute the method of any one of the first aspect.

[0013] According to a third aspect of the present application, an electronic device is provided, which includes: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores computer programs executable by the at least one processor, and the computer programs are executed by the at least one processor to cause the at least one processor to execute the method of any one of the implementation manners of the first aspect.

[0014] The heterogeneous database data migration method of the embodiment comprises: acquiring a collection package of objects to be migrated in different source databases, and parsing the collection package to obtain meta information; performing lexical and syntactic analysis on the objects to be migrated in the different source databases based on the meta information, so as to convert the objects to be migrated into structured syntax tree objects; performing normalization mapping on each structured syntax tree object to form a unified syntax tree of the heterogeneous source databases; performing migration and conversion on the syntax tree objects of the heterogeneous source databases and target syntax tree objects of a target database, so as to complete mapping of the syntax tree objects; calling a rule engine, so that the rule engine converts the mapped target syntax tree objects into target database object scripts by using conversion rules and rewriting rules, wherein the scripts are executed to migrate the objects to be migrated in the different source databases to the target database. By parsing the meta information in the source database collection package, the type of the source database is automatically determined, then the SQL of the source database is subjected to lexical and syntactic analysis to form a syntax tree object of the source database, object migration and conversion are performed on the syntax tree object of the source database and a target syntax tree object of a target database, and mapping of the syntax tree object is completed; the target syntax tree object is converted into a target database object script by using rule conversion and rewriting conditions, and automatic data migration is realized. BRIEF DESCRIPTION OF DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the specific embodiments of the present application or the prior art, the drawings needed to be used in the specific embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort.

[0016] Figure 1 is a flow chart of the heterogeneous database data migration method of the embodiment of the present application;

[0017] Figure 2 is a schematic diagram of the design principle of the heterogeneous database migration of the embodiment of the present application;

[0018] Figure 3 is a schematic diagram of the overall working mechanism of the heterogeneous database migration of the embodiment of the present application;

[0019] Figure 4 is a schematic diagram of the electronic device of the embodiment of the present application. DETAILED DESCRIPTION

[0020] In the following, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all the other embodiments obtained by a person of ordinary skill in the art without creative work should belong to the protection scope of the present application.

[0021] It should be noted that the terms "first", "second" and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented. In addition, the terms "comprise" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units does not necessarily limit to those clearly listed steps or units, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0022] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict. The present application will be described in detail below with reference to the drawings and in combination with the embodiments.

[0023] Implementing data synchronization between different types of databases usually includes the following key steps: first, determine the source database and the target database. The source database is the database from which we want to extract data, and the target database is the database to which we want to migrate data. The two databases may be of different types, with different data structures and characteristics, which is called "heterogeneous". Since the source database and the target database are heterogeneous, their data formats and structures may be completely different. Therefore, we need to convert the data change information in the source database into a format that the target database can understand and receive, and this process is achieved through some specific conversion rules and algorithms.

[0024] According to an embodiment of the present application, a heterogeneous database data migration method is provided, as shown in Figure 1 The method comprises the following steps 101 to 104:

[0025] Step 101: Obtain a collection package of objects to be migrated in different source databases, and parse the collection package to obtain meta information.

[0026] In this step, the collection bag refers to the complete expression of the migrated object in the source database, mainly including the SQL statements for creating databases, tables, views and other elements and the related statements for subsequent operations on them. The meta information refers to the identification and annotation of the lexical (such as keywords, constants, operators, etc.) and syntax (data types, functions, sequences, transaction processing, data dictionary, etc.) used in the source database, forming a series of lexical units. Each lexical unit is called a meta information.

[0027] Step 102: Based on the meta information, the lexical and syntax analysis of each of the different source databases to be migrated is performed to convert each of the to-be-migrated objects from unstructured text to a structured syntax tree object.

[0028] As an optional implementation of the present embodiment, based on the meta information, the lexical and syntax analysis of each of the to-be-migrated objects is performed to convert each of the to-be-migrated objects from unstructured text to a structured syntax tree object, which includes: determining the source database type corresponding to the to-be-migrated object based on the meta information; matching the lexical and syntax analysis method for the to-be-migrated object from the preset lexical and syntax library based on the source database type; performing lexical and syntax analysis on the to-be-migrated object respectively through the matched lexical and syntax analysis method; and marking the characteristic lexical and syntax.

[0029] In this optional implementation, different source databases may have some differences in lexical and syntax (such as: different date function expressions, SQL Server GETDATE(), ORACLE SYSDATE, MySQL CURRENT_TIMESTAMP or NOW(), SQL Server paging syntax, MySQL fuzzy query, ORACLE connection query, etc.), which need to be adjusted and processed according to the specific database type and version during parsing. The lexical and syntax analysis of the database, according to the lexical and syntax of different databases, compares and matches the meta information identified and annotated in the previous step according to the definition (lexical and syntax library) of each database. The system has built-in lexical and syntax libraries of multiple databases, and also supports user editing of lexical and syntax libraries. According to the lexical and syntax library, the source database object statement is intelligently disassembled and recognized, and the source database object definition is converted from unstructured text to a structured syntax tree object, while marking whether it is a characteristic syntax lexical. The characteristic syntax lexical includes but is not limited to integer type, string, date and time, string function, date function, table link, transaction processing, sequence, large object, and characteristic function.

[0030] Step 103: Normalizing mapping of each structured syntax tree object to form a unified syntax tree of the heterogeneous source database; migrating and converting the syntax tree object of the heterogeneous source database and the target syntax tree object of the target database to complete the mapping of the syntax tree object.

[0031] As an optional implementation of the embodiment, the normalization mapping of each structured syntax tree object to form a unified syntax tree object of the heterogeneous source database includes: based on the pre-defined unified syntax rule structure covering multiple databases, normalizing mapping of each structured syntax tree object to form a unified structured representation of the syntax tree object of the heterogeneous source database, wherein the characteristic syntax is supplemented in the normalization process.

[0032] In this step, the unified syntax rule structure covering multiple databases is defined, and the structured syntax tree object identified in the previous step is normalized to form a unified structured representation syntax tree. In the normalization process, the characteristic syntax and lexical units of other databases are supplemented, and a supplement identifier is added, and the content label is empty, which facilitates subsequent data conversion.

[0033] The object mapping between the source database and the target database is realized through the unified structured representation syntax tree. After generating the target database syntax tree object according to the unified structured representation syntax tree, the source database syntax tree is converted into the target database syntax tree through the object conversion rule and the rewriting condition, and the object definition is output.

[0034] Step 104: Calling the rule engine to convert the mapped target syntax tree object into the target database object script using the conversion rule and the rewriting rule, wherein the script is executed to migrate the objects to be migrated in different source databases to the target database.

[0035] In this step, a flexible rule engine is developed, which has built-in conversion rules of multiple heterogeneous databases. By translating the syntax of the source database and the target database, the implementation rules of the equivalent syntax in the target database are written, and each conversion mode is set to the rule engine. In this way, a rule chain is formed to perform conversion operations in a chained manner. When parsing the syntax tree, the corresponding syntax conversion rule is identified to rewrite the statement. Active learning is supported in training and actual use, and the conversion rule library is constantly enriched and refined. Plug-in architecture is adopted to facilitate the extension of source database types and target database types, and the conversion processing between heterogeneous databases is facilitated.

[0036] The conversion rewriting mainly aims at the basic requirements, non-basic requirements, characteristic syntax and other self-defined individual constraints of the database. The conversion rule is used to process the basic requirements, and the rewriting rule is used to process other contents.

[0037] ReferenceFigure 2 The illustrated heterogeneous database migration design principle automatically converts multi-source heterogeneous database objects into target database objects through intelligent translation technology, and supports conversion of various table objects and non-table objects including tables, views, stored procedures, functions, triggers, etc. By parsing the meta information in the source database collection package, the source database type is automatically determined, and then the SQL of the source database is parsed in terms of syntax and grammar to form a syntax tree object of the source database. The syntax tree object of the source database and the target database syntax tree object are migrated and converted, and the mapping of the syntax tree object is completed. The target syntax tree object is converted into a target database object script through rule conversion and rewriting conditions.

[0038] As an optional implementation manner of the embodiment, the rule engine converts the objects in the mapped target syntax tree into the target database object script by using conversion rules and rewriting rules, including: determining an adaptation layer based on the syntax tree object of the heterogeneous source database to be converted and the target syntax tree object; determining source-target conversion rules between the syntax tree object of the heterogeneous source database and the target syntax tree object in the adaptation layer; loading source-target rule conversion between the syntax tree object of the heterogeneous source database and the target syntax tree object after adaptation based on the source-target adaptation rules, and performing database rule conversion according to the source-target conversion rules; determining a source-target sentence rewriting mode between the syntax tree object of the heterogeneous source database and the target syntax tree object after the rule conversion is completed, and performing sentence rewriting to obtain the script.

[0039] As an optional implementation manner of the embodiment, a semantic analysis service is called to perform syntax checking on the script; if the checking is successful, the script is executed, otherwise the source-target sentence rewriting mode is called to perform rewriting to complete sentence correction.

[0040] In the optional implementation, according to the source-to-target database syntax tree object, it is judged to enter the corresponding adaptation layer, such as conversion from the M syntax tree object of Mysql to the K syntax tree object of Kingbase, according to the adaptation layer (O->K, O->MD, O->T, M->K, M->MD, M->T,...) to select the "M->K" adaptation, load the source-to-target adaptation rule, and the source-to-target adaptation rule includes specific conversion rules and rewriting rules. The rule conversion service is used to complete the source-to-target rule conversion according to the rule conversion table, and then the statement rewriting service is used to complete the related statement rewriting according to the pipeline, the special syntax and grammar, and the other self-defined rule rewriting table, to form the initial sql statement script of the target database, and the semantic analysis service is called to perform syntax detection and verification, if the verification is successful without syntax error, the SQL statement migration data is executed. The statement execution service connects the source database and the target database according to the sql statement script, executes the sql statement script, and migrates the source database data to the target database, if there is a syntax error, the related error is fed back to the statement rewriting service for revision.

[0041] As an optional implementation of the embodiment, the conversion rule is predefined before the rule engine is called, wherein the defined conversion rule includes replacement of the Cursor rule, the Open rule, the Case When rule and the For rule of different source databases according to the description mode of the target database.

[0042] In the optional implementation, the conversion rule is mainly for the Cursor rule, the Open rule, the Case When rule and the For rule, which are basic requirements of database programming, but there are certain differences between different databases, and the conversion rule is to replace all related contents according to the description mode of the target database. For example, the for loop statement in MySQL needs to be replaced by the While loop in SQL Server. Referring to Table 1, the conversion rule table is shown:

[0043] Table 1

[0044]

[0045] As an optional implementation of the embodiment, the rewriting rule is predefined before the rule engine is called: based on different types of target databases and whether the target database has a pipeline mechanism, the pipeline rule rewriting mode is defined.

[0046] As an optional implementation of the embodiment, the predefined rewriting rule further includes the special syntax and grammar rewriting rule defined for the special syntax and grammar of the target database.

[0047] In the above optional implementation, the rewriting rule is mainly for pipeline rules and other non-basic requirements, special syntax and other customized individual constraints.

[0048] ① Trigger rewriting when pipeline is encountered. Not all databases have pipeline mechanism, so there are two processing methods, refer to Table 2 pipeline rule rewriting comparison table: one is that the target database has pipeline mechanism, replace it with target database syntax; the other is that the target database does not have pipeline mechanism, rewrite the sql with the target database's timing task and batch processing to complete the processing and loading of data.

[0049] Table 2

[0050]

[0051] ② Add extension rules for special syntax and lexicon. When encountering the marked special syntax and lexicon, trigger rewriting and replace it with similar functions of the target database, refer to Table 3 for the special syntax rule rewriting comparison table.

[0052] Table 3

[0053]

[0054] ③ For customized individual constraints, add extension rules, which are similar to special syntax and lexicon. When encountered, replace it with pre-prepared extension rules.

[0055] In this embodiment, refer to Figure 3 the heterogeneous database migration handling mechanism shown in Figure 1, step 1: data source judgment. Obtain the source database script, analyze and parse the source database type through the built-in syntax and lexicon, obtain the source database and target database type; if the two source database types are consistent, enter "step 2", otherwise, alarm the user. Assume that it is converted from Mysql to Kingbase.

[0056] Step 2: Lexical syntax analysis. According to the source database type, analyze and identify the lexical syntax, and perform preliminary syntax checking to form a source database structured syntax tree object (such as Mysql), while marking the special syntax. According to the target database type, mark the lexical syntax that needs to be converted and transcribed, and then enter step 3.

[0057] Step 3: Constructing syntax tree object. According to the unified syntax rule structure, normalize the structured syntax tree object identified in the previous step to form a unified structured representation of the source database syntax tree object, and establish a mapping between the source database syntax tree and the target database syntax tree object to form a unified structured representation of the target database syntax tree object (such as Kingbase), and then enter step 4.

[0058] Step 4: SQL statement intelligent conversion. According to the source and target database syntax tree objects, it is judged to enter the corresponding adaptation layer, such as conversion from the M syntax tree object of Mysql to the K syntax tree object of Kingbase. According to the adaptation layer (O->K, O->MD, O->T, M->K, M->MD, M->T, …), it is selected to enter the "M->K" adaptation, the source and target adaptation rules are loaded, and the rule conversion service is utilized to complete the source and target rule conversion according to the rule conversion table. Then, the statement rewriting service is utilized to complete the relevant statement rewriting according to the pipeline, characteristic syntax lexicon and other self-defined rule rewriting table. The initial sql statement script of the target database is formed, and the semantic analysis service is called to perform syntax detection and verification. If the verification is successful and there is no syntax error, it enters step 5. If there is a syntax error, the relevant error is fed back to the statement rewriting service for revision.

[0059] Step 5: Execute SQL statement to migrate data. The statement execution service connects the source database and the target database according to the sql statement script, executes the sql statement script, and migrates the data of the source database to the target database.

[0060] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0061] According to the embodiments of the present application, the present application also provides an electronic device, comprising: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to implement the method described in any of the above embodiments.

[0062] According to the embodiments of the present application, the present application also provides a readable storage medium, which stores computer instructions for enabling a computer to implement the method described in any of the above embodiments when the computer executes the computer instructions.

[0063] According to the embodiments of the present application, the present application also provides a computer program product, which can implement the method described in any of the above embodiments when the processor executes the computer program.

[0064] Figure 4A schematic block diagram of an example electronic device 300 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices.

[0065] like Figure 4 As shown, the electronic device 300 includes a computing unit 301, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 302 or a computer program loaded from a storage unit 308 into a random access memory (RAM) 303. The RAM 303 may also store various programs and data required for the operation of the electronic device 300. The computing unit 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0066] Multiple components in electronic device 300 are connected to I / O interface 305, including: input unit 306, such as keyboard, mouse, etc.; output unit 307, such as various types of displays, speakers, etc.; storage unit 308, such as disk, optical disk, etc.; and communication unit 309, such as network card, modem, wireless transceiver, etc. Communication unit 309 allows electronic device 300 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0067] The computing unit 301 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 301 performs the various methods and processes described above, such as the object matching method. For example, in some embodiments, the object matching method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 300 via ROM 302 and / or communication unit 309. When the computer program is loaded into RAM 303 and executed by the computing unit 301, one or more steps of the methods described above may be performed.

[0068] The various embodiments of the systems and techniques described above can be implemented in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a load programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0069] Program code for carrying out methods of the present application can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces a means for implementing the functions / acts specified in the flowcharts and / or block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package, or entirely on a remote machine or server.

[0070] In the context of the present application, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium will include one or more lines of electrical connections, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

Claims

1. A method for migrating data from heterogeneous databases, characterized in that, include: Acquire the collection packages of objects to be migrated from different source databases, and parse the collection packages to obtain meta-information. Meta-information refers to a series of lexical units formed by identifying and annotating the lexical and grammatical structures used in the source databases. Each lexical unit is called a piece of meta-information. Based on the metadata, lexical and syntactic parsing is performed on the objects to be migrated in each of the different source databases to transform each object from unstructured text into a structured syntax tree object. This includes: determining the source database type corresponding to the object to be migrated based on the metadata; matching lexical and syntactic parsing methods for the object to be migrated from a preset lexical and syntactic library based on the source database type; performing lexical and syntactic parsing on the object to be migrated using the matched lexical and syntactic parsing methods respectively; and marking distinctive lexical and syntactic types, wherein the distinctive lexical and syntactic types include integer types, strings, date and time, string functions, date functions, table links, transaction processing, sequences, large objects, and distinctive functions. Normalize and map each structured syntax tree object to form a unified syntax tree for heterogeneous source databases. This includes normalizing and mapping each structured syntax tree object based on a predefined unified syntax rule structure covering multiple databases to form a syntax tree object for heterogeneous source databases with a unified structured representation. In the normalization process, characteristic lexical and grammatical features are added. The syntax tree objects of the heterogeneous source database and the target syntax tree objects of the target database are migrated and transformed to complete the mapping of syntax tree objects; The rule engine is invoked so that it can use transformation rules and rewriting rules to convert the mapped target syntax tree object into the target database object script. The rule engine has built-in transformation rules for various heterogeneous databases. By translating the syntax of the source database and the target database, it writes implementation rules for the equivalent syntax in the target database and sets each transformation method in the rule engine, thus forming a rule chain to perform the transformation operation in a chain manner. The process involves executing a script to migrate objects from different source databases to the target database. When a pipeline is encountered, a rewrite is triggered. Since not all databases have a pipeline mechanism, there are two approaches: 1) If the target database has a pipeline mechanism, the target database syntax is used instead; 2) If the target database does not have a pipeline mechanism, the SQL is rewritten using the target database's scheduled tasks and batch processing to complete data processing and loading. Extended rules are added for special lexical and grammatical features. When a marked special lexical or grammatical feature is encountered, a rewrite is triggered, replacing it with a similar function from the target database. For custom constraints, extended rules are added, similar to those for special lexical or grammatical features. When encountered, pre-defined extended rules are used to rewrite and replace them.

2. The heterogeneous database data migration method according to claim 1, characterized in that, The rule engine uses transformation rules and rewriting rules to convert objects in the mapped target syntax tree into the target database object. The script includes: determining an adaptation layer based on the syntax tree object of the heterogeneous source database to be converted and the target syntax tree object; The adaptation layer loads the source-to-target conversion rules between the syntax tree object of the heterogeneous source database and the target syntax tree object, and performs database rule conversion according to the source-to-target conversion rules. After the rule conversion is completed, the syntax tree object loaded from the heterogeneous source database and the target syntax tree object are rewritten using the source-destination statement rewriting method to obtain the script.

3. The heterogeneous database data migration method according to claim 2, characterized in that, The method also includes: calling a semantic analysis service to perform syntax validation on the script; If the verification is successful, the script will be executed; otherwise, the source and destination statement rewriting method will be invoked to complete the statement correction.

4. The heterogeneous database data migration method according to claim 3, characterized in that, Before calling the rule engine, the transformation rules are predefined. The defined transformation rules include replacing the Cursor rules, Open rules, Case When rules, and For rules of different source databases according to the description of the target database.

5. The heterogeneous database data migration method according to claim 4, characterized in that, Before calling the rule engine, the rewriting rules are predefined: based on the different types of target databases and whether the target database has a pipeline mechanism, the pipeline rule rewriting method is defined.

6. The heterogeneous database data migration method according to claim 5, characterized in that, Predefining rewriting rules also includes defining characteristic lexical and grammatical rewriting rules for different types of target databases.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the method according to any one of claims 1-6.

8. An electronic device, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to cause the at least one processor to perform the method according to any one of claims 1-6.

Citation Information

Patent Citations

  • SQL statement generation method and device, computer equipment and storage medium

    CN118568123A

  • Efficient adaptation method for heterogeneous database advanced object conversion

    CN120067074A