Database migration method and device, electronic equipment and storage medium
By building an intermediate library and utilizing metadata mapping relationships, data is migrated from the first database to the second database, solving the problem of direct migration of metadata between different databases and achieving stable data conversion and storage.
Patent Information
- Application Number
- CN202512057991.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-07
AI Technical Summary
Databases from different vendors differ significantly in their design philosophy, architecture, and implementation, making it impossible to directly migrate metadata to other types of databases.
By building an intermediate library and utilizing pre-built metadata mapping relationships, data from the first database is migrated to the intermediate library for format conversion, and then the converted data is stored in the second database, thus achieving data format unification.
It enables data migration between different databases, avoiding data quality and business interruption issues, and ensuring the stability and integrity of the data transformation process.
Smart Images

Figure CN121807812A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data migration technology, and in particular to a database migration method, apparatus, electronic device, and storage medium. Background Technology
[0002] In the wave of information technology, the strategic importance of databases is becoming increasingly prominent. The deepening digital transformation of various industries is placing higher demands on databases.
[0003] With the rapid development of database technology, enterprises often prefer database products with more powerful functions and better compatibility when selecting them. However, different vendors have significant differences in design philosophy, architecture, and implementation methods, which directly leads to differences in their metadata definition specifications and guidelines. Therefore, the metadata of a database may not be directly migrated to other types of databases. Summary of the Invention
[0004] This invention provides a database migration method, apparatus, electronic device, and storage medium to solve the problem that database metadata cannot be directly migrated to other types of databases.
[0005] According to one aspect of the present invention, a database migration method is provided, the method comprising:
[0006] The first database and the second database are identified. The first database contains the data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data stored in the first database and the second database have different data formats.
[0007] The intermediate library is built based on the pre-built metadata mapping relationship;
[0008] The first data in the first database is migrated to the intermediate database, and the data is transformed based on the metadata mapping relationship of the intermediate database to obtain the second data. The data format of the second data is the same as the data format used for data storage in the second database.
[0009] The second data is stored in the second database.
[0010] According to another aspect of the present invention, a database migration apparatus is provided, the apparatus comprising:
[0011] The database determination module is used to determine the first database and the second database. The first database contains the data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data stored in the first database and the second database have different data formats.
[0012] The intermediate library building module is used to build intermediate libraries based on pre-built metadata mapping relationships;
[0013] The data conversion module is used to migrate the first data from the first database to the intermediate database, and perform data conversion based on the metadata mapping relationship of the intermediate database to obtain the second data. The data format of the second data is the same as the data format used for data storage in the second database.
[0014] The data storage module is used to store the second data in the second database.
[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0016] At least one processor; and
[0017] A memory that is communicatively connected to at least one processor; wherein,
[0018] The memory stores a computer program that can be executed by at least one processor, such that the at least one processor is able to perform the database migration method of any embodiment of the present invention.
[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, which stores computer instructions for causing a processor to execute and implement the database migration method of any embodiment of the present invention.
[0020] The technical solution of this invention involves determining a first database and a second database. The first database contains data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data formats stored in the first and second databases are different. An intermediate database is constructed based on a pre-built metadata mapping relationship. The first data from the first database is migrated to the intermediate database, and data conversion is performed based on the metadata mapping relationship of the intermediate database to obtain the second data. The data format of the second data is the same as the data format used for data storage in the second database. The second data is then stored in the second database, thereby realizing data migration between the first and second databases. Furthermore, since the data mapping process is performed in the intermediate database, it can be ensured that the data conversion process does not cause data quality issues or business interruptions to the second database.
[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a flowchart of a database migration method provided in Embodiment 1 of the present invention;
[0024] Figure 2 This is a flowchart of another database migration method provided in Embodiment 2 of the present invention;
[0025] Figure 3 This is a schematic diagram of the structure of a database migration device according to Embodiment 3 of the present invention;
[0026] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the database migration method of this invention. Detailed Implementation
[0027] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] Example 1
[0030] Figure 1This invention provides a flowchart of a database migration method according to Embodiment 1. This embodiment is applicable to migrating data between two different databases. The method can be executed by a database migration device, which can be implemented in hardware and / or software and can be configured in an electronic device with data processing capabilities. Figure 1 As shown, the method includes:
[0031] S110. Determine the first database and the second database. The first database is the data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data stored in the first database and the second database have different data formats.
[0032] The first database can be the database that needs to be migrated, and the second database can be the database that carries the data in the first database.
[0033] Optionally, the first database is an Oracle database; the second database is a GoldenDB database.
[0034] S120. Build the intermediate library based on the pre-built metadata mapping relationship.
[0035] Metadata mapping relationships can be the data format mapping relationships required when converting data from the first database to the data format in the second database.
[0036] Metadata mapping relationships can be determined by defining the format of the same data in different databases, thereby establishing the mapping relationships between different databases.
[0037] Optional, the process of constructing metadata mapping relationships includes:
[0038] Determine the first sample data and the corresponding second sample data; the data format of the first sample data is the same as the data format of the data stored in the first database; the data format of the second sample data is the same as the data format of the data stored in the second database; the data content of the first sample data and the corresponding second sample data is the same.
[0039] Based on the first sample data and the second sample data corresponding to the first sample data, a metadata mapping relationship is constructed.
[0040] Sample data is determined in a first database and sample data is determined in a second database. The first and second sample data have the same content but different formats. Because the first and second sample data have the same content, the data formats of the same set of data in different databases can be directly determined, thus establishing the metadata mapping relationship between the databases.
[0041] S130. Migrate the first data from the first database to the intermediate database, and perform data conversion based on the metadata mapping relationship of the intermediate database to obtain the second data. The data format of the second data is the same as the data format used for data storage in the second database.
[0042] S140. Store the second data in the second database.
[0043] To avoid compatibility issues caused by direct migration, an intermediate database is established between the first and second databases. First, the first data in the first database is migrated to the intermediate database. The intermediate database then converts the first data into the second data through metadata mapping, and finally stores the second data in the second database.
[0044] By adopting the technical solution of this application, a first database and a second database are determined. The first database contains the data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data formats stored in the first database and the second database are different. An intermediate database is constructed based on a pre-built metadata mapping relationship. The first data in the first database is migrated to the intermediate database, and the data is converted based on the metadata mapping relationship of the intermediate database to obtain the second data. The data format of the second data is the same as the data format used for data storage in the second database. The second data is stored in the second database, thereby realizing the data migration between the first database and the second database. Since the data mapping process is carried out in the intermediate database, it can be ensured that the data conversion process does not cause problems such as data quality and business interruption in the second database.
[0045] Example 2
[0046] Figure 2 This invention provides a flowchart of another database migration method. This embodiment further optimizes the process of migrating first data from the first database to an intermediate database, based on the aforementioned embodiments. This embodiment can be combined with various optional solutions from one or more of the above embodiments. Figure 2 As shown, the database migration method in this embodiment may include the following steps:
[0047] S210. Determine the first database and the second database. The first database is the data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data stored in the first database and the second database have different data formats.
[0048] S220. Build the intermediate library based on the pre-built metadata mapping relationship.
[0049] S230. Migrate the first data in the first database to the intermediate database in batches, taking the first type as the unit; the first type is table type, index type, stored procedure type and / or trigger type.
[0050] When migrating data, it may not be necessary to migrate all the first data to the second database at once. Instead, the first data may be categorized and only a portion of the data may be migrated each time, thereby ensuring the stability of the migration process and avoiding excessive computational pressure on the equipment.
[0051] Therefore, the first data needs to be categorized. This is done based on a first type, which includes table type, index type, stored procedure type, and / or trigger type. During migration, the data is migrated in batches according to these different types.
[0052] Optionally, the first data in the first database is migrated to the intermediate database in batches, including:
[0053] Determine the migration batch for each batch of first sub-data; the first sub-data is obtained by dividing the first data according to the first type;
[0054] Each first sub-data item is migrated to the intermediate database in migration batches.
[0055] To ensure the sequential nature of data migration, a migration batch is determined for each first sub-data item, and migration is carried out sequentially according to the migration batch. This ensures the orderly nature of data migration and allows for data rollback based on the migration batch during subsequent rollback operations.
[0056] Optionally, after storing the second data in the second database, the method further includes:
[0057] Identify the second sub-data; the second sub-data is the data within the second data set that needs to have its migration cancelled.
[0058] Determine the migration batch corresponding to the second sub-data;
[0059] Based on the migration batch corresponding to the second sub-data, determine the first sub-data corresponding to the second sub-data, and re-migrate the first sub-data to the second database.
[0060] In practice, some data may need to be rolled back. Therefore, it is necessary to identify the second sub-data that needs to be rolled back and determine the migration batch corresponding to the second sub-data. Based on the migration batch, the first sub-data corresponding to the second sub-data can be identified. The second sub-data is then deleted from the second database, and the first sub-data is migrated from the first database again.
[0061] S240. Based on the metadata mapping relationship of the intermediate library, perform data transformation to obtain the second data. The data format of the second data is the same as the data format used by the second database for data storage.
[0062] S250. Store the second data in the second database.
[0063] By adopting the technical solution of this application, the first data in the first database is migrated to the intermediate database in batches according to the first type, thereby ensuring the orderliness of the data migration and enabling the rollback to be performed according to the migration batches when performing data rollback in the future.
[0064] Example 3
[0065] Figure 3 This invention provides a structural block diagram of a database migration device, applicable to situations involving the migration of data between two different databases. The database migration device can be implemented in hardware and / or software and can be configured in an electronic device with data processing capabilities. Figure 3 As shown, the database migration apparatus of this embodiment may include: a database determination module 310, an intermediate database construction module 320, a data conversion module 330, and a data storage module 340. Wherein:
[0066] The database determination module 310 is used to determine the first database and the second database. The first database is the data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data stored in the first database and the second database have different data formats.
[0067] The intermediate library building module 320 is used to build the intermediate library based on the pre-built metadata mapping relationship;
[0068] The data conversion module 330 is used to migrate the first data in the first database to the intermediate database, and perform data conversion based on the metadata mapping relationship of the intermediate database to obtain the second data. The data format of the second data is the data format used for data storage in the second database.
[0069] Data storage module 340 is used to store the second data in the second database.
[0070] Based on the above embodiments, optionally, the first database is an Oracle database; the second database is a GoldenDB database.
[0071] Based on the above embodiments, optionally, the feature is that migrating the first data in the first database to the intermediate database includes:
[0072] Data from the first database is migrated to the intermediate database in batches, based on the first type; the first type includes table type, index type, stored procedure type, and / or trigger type.
[0073] Based on the above embodiments, optionally, the first data in the first database is migrated to the intermediate database in batches, including:
[0074] Determine the migration batch for each batch of first sub-data; the first sub-data is obtained by dividing the first data according to the first type;
[0075] Each first sub-data item is migrated to the intermediate database in migration batches.
[0076] Based on the above embodiments, optionally, after storing the second data in the second database, the method further includes:
[0077] Identify the second sub-data; the second sub-data is the data within the second data set that needs to have its migration cancelled.
[0078] Determine the migration batch corresponding to the second sub-data;
[0079] Based on the migration batch corresponding to the second sub-data, determine the first sub-data corresponding to the second sub-data, and re-migrate the first sub-data to the second database.
[0080] Based on the above embodiments, optionally, the process of constructing metadata mapping relationships includes:
[0081] Determine the first sample data and the corresponding second sample data; the data format of the first sample data is the same as the data format of the data stored in the first database; the data format of the second sample data is the same as the data format of the data stored in the second database; the data content of the first sample data and the corresponding second sample data is the same.
[0082] Based on the first sample data and the second sample data corresponding to the first sample data, a metadata mapping relationship is constructed.
[0083] The database migration apparatus provided in this embodiment of the invention can execute the database migration method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0084] Example 4
[0085] Figure 4A schematic diagram of an electronic device 10, which 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 can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0086] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0087] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0088] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 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 processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as database migration methods.
[0089] In some embodiments, the database migration method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the database migration method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the database migration method by any other suitable means (e.g., by means of firmware).
[0090] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0091] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0092] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0093] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0094] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0095] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0096] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0097] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A database migration method, characterized in that, include: A first database and a second database are identified. The first database contains the data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data formats stored in the first database and the second database are different; The intermediate library is built based on the pre-built metadata mapping relationship; The first data in the first database is migrated to the intermediate database, and the data is transformed based on the metadata mapping relationship of the intermediate database to obtain the second data. The data format of the second data is the data format used for data storage in the second database. The second data is stored in the second database.
2. The method according to claim 1, characterized in that, The first database is an Oracle database; the second database is a GoldenDB database.
3. The method according to claim 1, characterized in that, Migrating the first data from the first database to the intermediate database includes: The first data in the first database is migrated to the intermediate database in batches, based on the first type; the first type is a table type, an index type, a stored procedure type, and / or a trigger type.
4. The method according to claim 3, characterized in that, The first data in the first database is migrated to the intermediate database in batches, including: Determine the migration batch for each batch of first sub-data; the first sub-data is obtained by dividing the first data according to the first type; Each first sub-data item is migrated to the intermediate database in migration batches.
5. The method according to claim 4, characterized in that, After storing the second data in the second database, the process also includes: Determine the second sub-data; the second sub-data is the data in the second data that needs to be cancelled from migration. Determine the migration batch corresponding to the second sub-data; Based on the migration batch corresponding to the second sub-data, determine the first sub-data corresponding to the second sub-data, and re-migrate the first sub-data to the second database.
6. The method according to claim 1, characterized in that, The process of constructing the metadata mapping relationship includes: Determine the first sample data and the corresponding second sample data; the data format of the first sample data is the same as the data format of the data stored in the first database; the data format of the second sample data is the same as the data format of the data stored in the second database; the data content of the first sample data and the corresponding second sample data is the same. Based on the first sample data and the second sample data corresponding to the first sample data, the metadata mapping relationship is constructed.
7. A database migration device, characterized in that, include: The database determination module is used to determine a first database and a second database, wherein the first database is the data that needs to be migrated, and the second database is the database that receives the migrated data from the first database. The data formats stored in the first database and the second database are different; The intermediate library building module is used to build intermediate libraries based on pre-built metadata mapping relationships; The data conversion module is used to migrate the first data in the first database to the intermediate database, and perform data conversion based on the metadata mapping relationship of the intermediate database to obtain the second data. The data format of the second data is the data format used for data storage in the second database. A data storage module is used to store the second data in the second database.
8. The apparatus according to claim 7, characterized in that, The first database is an Oracle database; the second database is a GoldenDB database.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the database migration method according to any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the database migration method according to any one of claims 1-6.