Data migration method and device based on database link, equipment and medium
By using the sandbox process for data type conversion and isolation fault handling in heterogeneous database migration, the problems of complex heterogeneous database migration process and insufficient security are solved, simplifying the process and improving data security.
Patent Information
- Application Number
- CN202411028901.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-11
AI Technical Summary
During the migration process of heterogeneous databases, existing technologies have problems such as cumbersome configuration, compatibility issues, and insufficient security, making the migration process complex and unsafe.
By introducing a sandbox process into the source database, establishing a connection with the target database, performing data type conversion and query result processing, unified management of data sending and receiving, and isolating faults in the sandbox process to avoid process crashes caused by abnormal data input. risk.
It simplifies the data migration process, improves data security, avoids the risk of process crash in the source database due to abnormal data input, and reduces the complexity of the source database.
Smart Images

Figure CN118760669A_ABST
Abstract
Description
Technical Field
[0001] The present application is applicable to the field of database technology, and in particular, relates to a data migration method, device, equipment and medium based on database links. Background Art
[0002] In the practice of database migration using database links, data transfer between multiple heterogeneous databases is often involved. This process requires cooperation between databases, which is not only cumbersome but also involves security risks. Among them, factors such as data type conversion, differences in data storage formats, and different query syntax make data migration between heterogeneous databases more complicated.
[0003] The existing heterogeneous database migration between Oracle and SQL Server is implemented through the "database gateway" function. Oracle database accesses non-Oracle database systems through the database gateway because the database gateway allows Oracle database to execute SQL statements to access, add, modify or delete data stored in heterogeneous database systems. Among them, the process of configuring the database gateway is relatively cumbersome, and there may be unknown compatibility issues between the source database and the target database, which can easily cause the source database process to crash and security cannot be fully guaranteed. In addition, other heterogeneous database migrations may involve operations such as installing extensions, creating external servers, using user mappings and external tables, and even processing data independently of the database itself, which makes the migration process cumbersome and unable to guarantee data security.
[0004] Therefore, how to optimize the heterogeneous database migration process, simplify the data migration process and ensure the security of data input has become an urgent problem to be solved. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a data migration method, apparatus, device and medium based on database links to solve the problem of how to optimize the heterogeneous database migration process, simplify the data migration process and ensure the security of data input.
[0006] In a first aspect, an embodiment of the present application provides a data migration method based on a database link, the data migration method is applied to a sandbox process of a source database, the sandbox process and the source database are isolated, and includes:
[0007] After the source database starts the sandbox process, according to the database links between the source database and the first target database and the second target database, respectively establish connections between the sandbox process and the first target database and the second target database;
[0008] The sandbox process sends the query request sent by the source database to the first target database, and the first target database is used to feedback the query result according to the query request;
[0009] Acquire the query result, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source database, where the data type of the first conversion result is the data storage type of the source database, the source database is used to store the first conversion result, and send the stored first conversion result and an insert request to the second target database to the sandbox process;
[0010] The sandbox process obtains the first conversion result and the insert request sent by the source database, performs data type conversion on the first conversion result to obtain a second conversion result, and the data type of the second conversion result is the data storage type of the second target database;
[0011] The insert request and the second conversion result are sent to the second target-side database, and the second target-side database is used to migrate and insert the second conversion result according to the insert request.
[0012] In a second aspect, an embodiment of the present application provides a data migration method based on a database link, the data migration method being applied to the source database described in the data migration method described in the first aspect above, comprising:
[0013] After the source database establishes database links with the first target database and the second target database respectively, the sandbox process is started, and metadata information of the database link is sent to the sandbox process, and the sandbox process is used to establish connections between the sandbox process and the first target database and the second target database respectively according to the metadata information of the database link;
[0014] Sending a query request for the first target database to the sandbox process, the sandbox process is used to send the query request to the first target database, and obtain a query result fed back by the first target database according to the query request, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source database, the data type of the first conversion result is the data storage type of the source database;
[0015] Acquire and store the first conversion result, send the stored first conversion result and an insert request for the second target database to the sandbox process, the sandbox process is used to perform data type conversion on the acquired first conversion result to obtain a second conversion result, and send the insert request and the second conversion result to the second target database, the data type of the second conversion result is the data storage type of the second target database, and the second target database is used to migrate and insert the second conversion result according to the insert request.
[0016] In a third aspect, an embodiment of the present application provides a data migration device based on a database link, wherein the data migration device is applied to a sandbox process of a source database, and the sandbox process is isolated from the source database, including:
[0017] a connection module, configured to establish, after the source database starts the sandbox process, connections between the sandbox process and the first target database and the second target database according to database links between the source database and the first target database and the second target database;
[0018] A first sending module, configured to send the query request sent by the source database to the first target database, wherein the first target database is configured to feedback the query result according to the query request;
[0019] a first conversion module, configured to obtain the query result, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source database, wherein the data type of the first conversion result is the data storage type of the source database, the source database is configured to store the first conversion result, and send the stored first conversion result and an insert request to the second target database to the sandbox process;
[0020] A second conversion module is used to obtain the first conversion result and the insert request sent by the source database, perform data type conversion on the first conversion result to obtain a second conversion result, and the data type of the second conversion result is the data storage type of the second target database;
[0021] The second sending module is used to send the insertion request and the second conversion result to the second target database, and the second target database is used to migrate and insert the second conversion result according to the insertion request.
[0022] In a fourth aspect, an embodiment of the present application provides a data migration device based on database links, wherein the data migration device is applied to the source database described in the data migration method described in the first aspect, including:
[0023] A process launching module, used to launch the sandbox process after the source database respectively establishes database links with the first target database and the second target database, and send metadata information of the database link to the sandbox process, and the sandbox process is used to establish connections between the sandbox process and the first target database and the second target database according to the metadata information of the database link;
[0024] a query request sending module, configured to send a query request for the first target-side database to the sandbox process, wherein the sandbox process is configured to send the query request to the first target-side database, obtain a query result fed back by the first target-side database according to the query request, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source-side database, wherein the data type of the first conversion result is a data storage type of the source-side database;
[0025] An insert request sending module is used to obtain and store the first conversion result, and send the stored first conversion result and the insert request for the second target database to the sandbox process. The sandbox process is used to perform data type conversion on the obtained first conversion result to obtain a second conversion result, and send the insert request and the second conversion result to the second target database. The data type of the second conversion result is the data storage type of the second target database. The second target database is used to migrate and insert the second conversion result according to the insert request.
[0026] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements the data migration method described in the first aspect or the data migration method described in the second aspect.
[0027] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data migration method described in the first aspect or the data migration method described in the second aspect is implemented.
[0028] Compared with the prior art, the embodiments of the present application have the following beneficial effects: after the source database starts the sandbox process, the present application establishes connections between the sandbox process and the first target database and the second target database according to the database links between the source database and the first target database and the second target database, respectively, sends the query request sent by the acquired source database to the first target database, acquires the query result fed back by the first target database according to the query request, performs data type conversion on the query result to obtain a first conversion result, and sends the first conversion result to the source database, the data type of the first conversion result is the data storage type of the source database, acquires the first conversion result and the insert request sent by the source database, performs data type conversion on the first conversion result to obtain a second conversion result, the data type of the second conversion result is the data storage type of the second target database, and sends the insert request and the second conversion result to the second target database, so that the second target database migrates and inserts the second conversion result according to the insert request. Using the sandbox process to uniformly manage data sending and receiving means that the source database does not need to locally adapt to the processing procedures of various heterogeneous databases. It only needs to process the data returned by the sandbox process, which simplifies and standardizes the process. At the same time, the sandbox process also has the function of isolating faults. Abnormal data input will be identified and intercepted in advance on the sandbox process, avoiding the risk of the source database process crashing due to abnormal data input. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0030] Figure 1 This is a schematic diagram of an application environment of a data migration method based on database links provided in Embodiment 1 of the present application;
[0031] Figure 2 It is a flowchart of a data migration method based on database link provided in the second embodiment of the present application;
[0032] Figure 3 It is a flowchart of a data migration method based on database link provided in Embodiment 3 of the present application;
[0033] Figure 4 It is a structural diagram of a data migration device based on database link provided in the fourth embodiment of the present application;
[0034] Figure 5It is a structural schematic diagram of a data migration device based on database link provided in Embodiment 5 of the present application;
[0035] Figure 6 It is a structural diagram of a computer device provided in Example 6 of the present application. DETAILED DESCRIPTION
[0036] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0037] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0038] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0039] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0040] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0041] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0042] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0043] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0044] It should be understood that the size of the serial numbers of the steps in the following embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0045] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0046] The data migration method based on database link provided in the first embodiment of the present application can be applied to Figure 1 In an application environment, the source-end database, the first target-end database, and the second target-end database form a group of databases for implementing a migration operation of data in the first target-end database to the second target-end database.
[0047] In the first embodiment of the present application, an external sandbox process is created, and the sandbox process establishes a protocol layer connection with the source database, the first target database, and the second target database. The sandbox process includes a data type mapping layer and a protocol data transceiver layer. The sandbox process is a daemon process of the source database process and will be pulled up when Database Link is used to perform DML operations or DQL operations. The sandbox process establishes connections with two heterogeneous databases, the first target database and the second target database, and pulls the table data in the first target database in batches to the source database through the data type mapping layer and the protocol data transceiver layer, and then sends these table data from the source database to the second target database through the sandbox process for data table insertion.
[0048] The data type mapping layer and protocol data receiving and sending layer of the sandbox process manage data sending and receiving in a unified manner, which means that the source database does not need to adapt to the processing of various heterogeneous databases locally, but only needs to process the data returned by the sandbox process, simplifying and standardizing the process. At the same time, the sandbox process also has the function of isolating faults. If the heterogeneous database on the target side has abnormal data input, it will be identified and intercepted in advance on the sandbox process, avoiding the risk of the source database crashing due to abnormal data input.
[0049] Among them, the above-mentioned databases can be implemented by relying on computer devices including but not limited to handheld computers, desktop computers, laptops, ultra-mobile personal computers (Ultra-Nobile Personal Computer, UMPC), netbooks, cloud computer devices, personal digital assistants (Personal Digital Assistant, PDA), etc., and can also be implemented by relying on independent servers or cluster servers.
[0050] See also Figure 2 , is a flow chart of a data migration method based on database link provided in the second embodiment of the present application, the data migration method is applied to Figure 1 In the sandbox process, the sandbox process and the source database are isolated. Figure 2 As shown, the data migration method based on database link may include the following steps:
[0051] Step S201, after the source database starts the sandbox process, according to the database links between the source database and the first target database and the second target database, connections are established between the sandbox process and the first target database and the second target database.
[0052] Among them, the source database and the sandbox process are isolated configurations, and the source database and the sandbox process have corresponding communication protocols, so that the source database can interact with the sandbox process. After obtaining the instruction or operation of data migration, the source database will determine the starting database and the target database of the data migration. In this application, the revelation database is defined as the first target database, and the target database is defined as the second target database. It can be seen that the data table in the first target database needs to be migrated to the second target database.
[0053] Since the source database is connected to the first target database and the second target database in the form of a database link, after the sandbox process is started, connections are established between the sandbox process and the first target database and the second target database respectively, so that data interaction can be performed with the first target database and the second target database, and the data interaction includes the sending and receiving of data or instructions.
[0054] In step S202, the sandbox process sends the query request sent by the source database to the first target database, and the first target database is used to feedback the query result according to the query request.
[0055] After obtaining the instruction or operation of data migration, the source database generates a corresponding query request and an insert request, and the query request is a request for querying the data table from the first target database. The source database sends the generated query request to the sandbox process, so that the sandbox process forwards the query request to the first target database, so that the sandbox process can obtain the query result fed back by the first target database.
[0056] After receiving the query request, the first target database executes the corresponding query request, thereby obtaining the query result after executing the query request, and feeding back the query result to the sandbox process connected to it. For example, the query request is SELECT*FROM T1, which means querying the records in the data table T1 from the first target database.
[0057] In addition, the database link information in the above step S201 and the query request in step S202 can be sent to the sandbox process by the source database at the same time. The sandbox process determines to establish a connection with the first target database through the database link information and then sends the query request.
[0058] Step S203, obtaining the query result, performing data type conversion on the query result to obtain a first conversion result, and sending the first conversion result to the source database.
[0059] The data type of the first conversion result is the data storage type of the source database, and the source database is used to store the first conversion result and send the stored first conversion result and the insertion request to the second target database to the sandbox process.
[0060] For the query results fed back by the first target database obtained by the sandbox process, the data type of the query results needs to be converted in the sandbox process to achieve the same data type as the source database, so that it can be used for storage and other operations of the source database. Through this conversion process, data conversion of heterogeneous databases can be achieved, preparing for data migration to another heterogeneous database.
[0061] At this time, the converted data can be detected by the sandbox process, which can effectively prevent invalid and malicious data from entering the source database, thereby improving the security of the source database.
[0062] Of course, if the data storage type of the source database is the same as the data storage type of the first target database, no conversion is required.
[0063] Optionally, the sandbox process includes a heterogeneous database data type mapping layer, which performs data type conversion on the query result to obtain a first conversion result, including:
[0064] In the sandbox process, detecting the data storage type of the first target database corresponding to the query result to obtain a first data type;
[0065] Get the data storage type of the source database;
[0066] The query result is converted from the first data type mapping to the data storage type of the source database using the heterogeneous database data type mapping layer to obtain a first conversion result.
[0067] Among them, a heterogeneous database data type mapping layer is set in the sandbox process, that is, the heterogeneous database data type mapping layer is configured with mapping functions, mapping tables, etc., which can realize the conversion of data from one type to another. Taking the first target database as an Oracle database as an example, because Oracle's float type is a subtype of number, binary_float is a native float type, and the source database uses native number type and float type, the sandbox process needs to map Oracle's float type to the native number type and Oracle's binary_float type to the native float type through the heterogeneous database data type mapping layer. Finally, adjust the query result based on the type mapping to ensure the data consistency in the first conversion result after conversion.
[0068] The heterogeneous database data type mapping layer of the sandbox process can store mapping functions, mapping tables, etc. of all databases that are heterogeneous with the source database, thereby helping to match the data to the corresponding conversion method and obtain accurate conversion results.
[0069] Step S204: The sandbox process obtains the first conversion result and the insert request sent by the source database, performs data type conversion on the first conversion result, and obtains a second conversion result.
[0070] The data type of the second conversion result is the data storage type of the second target database. As the intermediary of data migration, the source database needs to store the corresponding data in its own cache before sending the corresponding data to the second target database for insertion. For example, the insert request is INSERT INTO T2 values(?), where values() is used to represent the data to be inserted (i.e., the second conversion result), and T2 is the second target database.
[0071] For the sandbox process, no data is stored therein, and the data queried from the first target database is cached in the source database. Therefore, the source database is required to send the cached first conversion result and insert request to the sandbox process so that the sandbox process can send the first conversion data to the second target database.
[0072] Of course, if the data type of the first conversion result (ie, the data storage type of the source-end database) is the same as the data storage type of the second target-end database, no conversion is required.
[0073] Optionally, performing data type conversion on the first conversion result to obtain a second conversion result includes:
[0074] In the sandbox process, detecting the data storage type of the second target database to obtain a second data type;
[0075] The heterogeneous database data type mapping layer is used to convert the first conversion result from the data storage type mapping of the source database into a second data type to obtain a second conversion result.
[0076] Among them, the sandbox process performs data type mapping and conversion between heterogeneous databases, and the sandbox process adjusts the result set data through the heterogeneous database data type mapping layer. Taking the second target database as an example, the MySQL database also uses the native number type and float type, and the source database also uses the native number type and float type. Therefore, the heterogeneous database data type mapping layer does not need to be processed at this time.
[0077] Step S205: sending the insert request and the second conversion result to the second target database.
[0078] The second target-end database is used to migrate and insert the second conversion result according to the insertion request.
[0079] After the sandbox process obtains the insert request and the second conversion result, the second conversion result can be merged with the insert request to form an insert request containing the second conversion result. After sending the insert request and the second conversion result to the second target database, the second target database inserts the second conversion result into the second target database according to the insert request.
[0080] In an embodiment of the present application, after the source database starts the sandbox process, according to the database links between the source database and the first target database and the second target database, connections are established between the sandbox process and the first target database and the second target database respectively, and the query request sent by the source database is sent to the first target database, and the query result fed back by the first target database according to the query request is obtained, and the data type of the query result is converted to obtain a first conversion result, and the first conversion result is sent to the source database, and the data type of the first conversion result is the data storage type of the source database, and the first conversion result and the insert request sent by the source database are obtained, and the data type of the first conversion result is converted to obtain a second conversion result, and the data type of the second conversion result is the data storage type of the second target database, and the insert request and the second conversion result are sent to the second target database, so that the second target database migrates and inserts the second conversion result according to the insert request. Using the sandbox process to uniformly manage data transmission and reception means that the source database does not need to adapt to the processing of various heterogeneous databases locally. It only needs to process the data returned by the sandbox process, which simplifies and standardizes the process. At the same time, the sandbox process also has the function of isolating faults. Abnormal data input will be identified and intercepted in advance on the sandbox process, avoiding the risk of the source database crashing due to abnormal data input. Figure 3 , is a flow chart of a data migration method based on database link provided in Example 3 of the present application. Figure 3 As shown, the data migration method may include the following steps:
[0081] Step S301, after the source database establishes database links with the first target database and the second target database respectively, the sandbox process is started and metadata information of the database link is sent to the sandbox process.
[0082] The sandbox process is used to establish connections between the sandbox process and the first target-end database and the second target-end database respectively according to metadata information of the database link.
[0083] Step S302: Send a query request for the first target database to the sandbox process.
[0084] Among them, the sandbox process is used to send a query request to the first target database, and obtain the query result fed back by the first target database according to the query request, convert the data type of the query result to obtain a first conversion result, and send the first conversion result to the source database. The data type of the first conversion result is the data storage type of the source database.
[0085] Step S303, obtaining and storing the first conversion result, and sending the stored first conversion result and an insert request to the second target database to the sandbox process.
[0086] Among them, the sandbox process is used to convert the data type of the acquired first conversion result to obtain a second conversion result, and send an insert request and the second conversion result to the second target database. The data type of the second conversion result is the data storage type of the second target database. The second target database is used to migrate and insert the second conversion result according to the insert request.
[0087] Specifically, please refer to the contents of the above steps S201 to S205, which will not be elaborated here.
[0088] Optionally, the source database includes a first protocol data transceiver layer, the sandbox process includes a second protocol data transceiver layer, and the first protocol data transceiver layer performs protocol interaction with the second protocol data transceiver layer to achieve data transmission between the source database and the sandbox process.
[0089] Optionally, the source database includes a result set buffer, and the result set buffer is used to store the first conversion result.
[0090] The embodiment of the present application isolates the source database from the sandbox process, which can effectively reduce the input of abnormal data and avoid the risk of the source database process crashing due to abnormal data input. The conversion of data is uniformly supervised by the sandbox process, and there is no need to configure the adaptation conversion function in the source database, thereby reducing the complexity of the source database.
[0091] Corresponding to the data migration method based on database link in the above embodiment, Figure 4 The structure diagram of the data migration device based on database link provided by the fourth embodiment of the present application is shown. The data migration device is applied to Figure 1 For ease of description, only the parts related to the embodiment of the present application are shown.
[0092] See also Figure 4 , the data migration device comprises:
[0093] A connection module 41 is used to establish connections between the sandbox process and the first target database and the second target database respectively according to database links between the source database and the first target database and the second target database after the sandbox process is started in the source database;
[0094] A first sending module 42 is used for the sandbox process to send the query request sent by the source database to the first target database, and the first target database is used to feedback the query result according to the query request;
[0095] A first conversion module 43 is used to obtain a query result, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source database. The data type of the first conversion result is the data storage type of the source database. The source database is used to store the first conversion result, and send the stored first conversion result and an insert request to the second target database to the sandbox process.
[0096] The second conversion module 44 is used for the sandbox process to obtain the first conversion result and the insert request sent by the source database, and perform data type conversion on the first conversion result to obtain a second conversion result, where the data type of the second conversion result is the data storage type of the second target database;
[0097] The second sending module 45 is used to send the insert request and the second conversion result to the second target database, and the second target database is used to migrate and insert the second conversion result according to the insert request.
[0098] Optionally, the sandbox process includes a heterogeneous database data type mapping layer, a first conversion module 43, including:
[0099] A first detection unit is used to detect, in a sandbox process, a data storage type of a first target-end database corresponding to a query result, and obtain a first data type;
[0100] A first acquisition unit is used to acquire a data storage type of a source database;
[0101] The first conversion unit is used to use the heterogeneous database data type mapping layer to convert the query result from the first data type mapping to the data storage type of the source database to obtain a first conversion result.
[0102] Optionally, the second conversion module 44 includes:
[0103] A second detection unit is used to detect the data storage type of the second target end database in the sandbox process to obtain a second data type;
[0104] The second conversion unit is used to use the heterogeneous database data type mapping layer to convert the first conversion result from the data storage type mapping of the source database into a second data type to obtain a second conversion result.
[0105] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0106] Corresponding to the data migration method based on database link in the above embodiment, Figure 5 The structure diagram of the data migration device based on database link provided by the fourth embodiment of the present application is shown. The data migration device is applied to Figure 1 For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0107] See also Figure 5 , the data migration device comprises:
[0108] The process launching module 51 is used to launch the sandbox process after the source database establishes database links with the first target database and the second target database respectively, and send metadata information of the database link to the sandbox process, and the sandbox process is used to establish connections between the sandbox process and the first target database and the second target database respectively according to the metadata information of the database link;
[0109] A query request sending module 52 is used to send a query request for the first target database to the sandbox process. The sandbox process is used to send the query request to the first target database, obtain the query result fed back by the first target database according to the query request, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source database. The data type of the first conversion result is the data storage type of the source database.
[0110] The insert request sending module 53 is used to obtain and store the first conversion result, and send the stored first conversion result and the insert request for the second target database to the sandbox process. The sandbox process is used to perform data type conversion on the obtained first conversion result to obtain the second conversion result, and send the insert request and the second conversion result to the second target database. The data type of the second conversion result is the data storage type of the second target database. The second target database is used to migrate and insert the second conversion result according to the insert request.
[0111] Optionally, the source database includes a first protocol data transceiver layer, the sandbox process includes a second protocol data transceiver layer, and the first protocol data transceiver layer performs protocol interaction with the second protocol data transceiver layer to achieve data transmission between the source database and the sandbox process.
[0112] Optionally, the source database includes a result set buffer, and the result set buffer is used to store the first conversion result.
[0113] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0114] Figure 6 This is a schematic diagram of the structure of a computer device provided in Example 6 of the present application. Figure 6 As shown, the computer device of this embodiment includes: at least one processor ( Figure 6 Only one is shown), a memory, and a computer program stored in the memory and executable on at least one processor, wherein when the processor executes the computer program, the steps in any of the above-mentioned data migration method embodiments based on database links are implemented.
[0115] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 6 This is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.
[0116] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0117] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of an operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments may also be an external storage device of a computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on a computer device. Further, the memory may also include both an internal storage unit of a computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program codes of computer programs, etc. The memory may also be used to temporarily store data that has been output or is to be output.
[0118] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned method embodiment when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0119] The present application implements all or part of the processes in the above-mentioned embodiment method, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing the computer program product.
[0120] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0121] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0122] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0123] 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 units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0124] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data migration method based on database link, characterized in that: The data migration method is applied to a sandbox process of a source database, wherein the sandbox process and the source database are isolated from each other, and includes: After the source database starts the sandbox process, according to the database links between the source database and the first target database and the second target database, respectively establish connections between the sandbox process and the first target database and the second target database; The sandbox process sends the query request sent by the source database to the first target database, and the first target database is used to feed back the query result according to the query request; Acquire the query result, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source database, where the data type of the first conversion result is the data storage type of the source database, the source database is used to store the first conversion result, and send the stored first conversion result and an insert request to the second target database to the sandbox process; The sandbox process obtains the first conversion result and the insert request sent by the source database, performs data type conversion on the first conversion result to obtain a second conversion result, and the data type of the second conversion result is the data storage type of the second target database; The insert request and the second conversion result are sent to the second target-side database, and the second target-side database is used to migrate and insert the second conversion result according to the insert request.
2. The data migration method according to claim 1, characterized in that: The sandbox process includes a heterogeneous database data type mapping layer, and the data type conversion of the query result to obtain a first conversion result includes: In the sandbox process, detecting a data storage type of a first target-end database corresponding to the query result to obtain a first data type; Obtain the data storage type of the source database; The query result is converted from the first data type mapping to the data storage type of the source database using the heterogeneous database data type mapping layer to obtain a first conversion result.
3. The data migration method according to claim 2, characterized in that: The performing data type conversion on the first conversion result to obtain a second conversion result includes: In the sandbox process, detecting the data storage type of the second target database to obtain a second data type; The heterogeneous database data type mapping layer is used to convert the first conversion result from the data storage type mapping of the source database into the second data type to obtain a second conversion result.
4. A data migration method based on database link, characterized in that: The data migration method is applied to the source database described in the data migration method according to any one of claims 1 to 3, comprising: After the source database establishes database links with the first target database and the second target database respectively, the sandbox process is started, and metadata information of the database link is sent to the sandbox process, and the sandbox process is used to establish connections between the sandbox process and the first target database and the second target database respectively according to the metadata information of the database link; Sending a query request for the first target database to the sandbox process, the sandbox process is used to send the query request to the first target database, and obtain a query result fed back by the first target database according to the query request, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source database, the data type of the first conversion result is the data storage type of the source database; Acquire and store the first conversion result, send the stored first conversion result and an insert request for the second target database to the sandbox process, the sandbox process is used to perform data type conversion on the acquired first conversion result to obtain a second conversion result, and send the insert request and the second conversion result to the second target database, the data type of the second conversion result is the data storage type of the second target database, and the second target database is used to migrate and insert the second conversion result according to the insert request.
5. The data migration method according to claim 4, characterized in that: The source-end database includes a first protocol data transceiving layer, and the sandbox process includes a second protocol data transceiving layer. The first protocol data transceiving layer interacts with the second protocol data transceiving layer to implement data transmission between the source-end database and the sandbox process.
6. The data migration method according to claim 4, characterized in that: The source-end database includes a result set buffer, and the result set buffer is used to store the first conversion result.
7. A data migration device based on database link, characterized in that: The data migration device is applied to a sandbox process of the source database, and the sandbox process is isolated from the source database, including: a connection module, configured to establish, after the source database starts the sandbox process, connections between the sandbox process and the first target database and the second target database according to database links between the source database and the first target database and the second target database; A first sending module, configured for the sandbox process to send the query request sent by the source database to the first target database, and the first target database is configured to feedback the query result according to the query request; a first conversion module, configured to obtain the query result, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source database, wherein the data type of the first conversion result is the data storage type of the source database, the source database is configured to store the first conversion result, and send the stored first conversion result and an insert request to the second target database to the sandbox process; A second conversion module is used for the sandbox process to obtain the first conversion result and the insert request sent by the source database, perform data type conversion on the first conversion result to obtain a second conversion result, and the data type of the second conversion result is the data storage type of the second target database; The second sending module is used to send the insertion request and the second conversion result to the second target database, and the second target database is used to migrate and insert the second conversion result according to the insertion request.
8. A data migration device based on database link, characterized in that: The data migration device is applied to the source database in the data migration method according to any one of claims 1 to 3, comprising: A process launching module, used to launch the sandbox process after the source database respectively establishes database links with the first target database and the second target database, and send metadata information of the database link to the sandbox process, and the sandbox process is used to establish connections between the sandbox process and the first target database and the second target database according to the metadata information of the database link; a query request sending module, configured to send a query request for the first target-side database to the sandbox process, wherein the sandbox process is configured to send the query request to the first target-side database, obtain a query result fed back by the first target-side database according to the query request, perform data type conversion on the query result to obtain a first conversion result, and send the first conversion result to the source-side database, wherein the data type of the first conversion result is a data storage type of the source-side database; An insert request sending module is used to obtain and store the first conversion result, and send the stored first conversion result and the insert request for the second target database to the sandbox process. The sandbox process is used to perform data type conversion on the obtained first conversion result to obtain a second conversion result, and send the insert request and the second conversion result to the second target database. The data type of the second conversion result is the data storage type of the second target database. The second target database is used to migrate and insert the second conversion result according to the insert request.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the data migration method according to any one of claims 1 to 3 or the data migration method according to any one of claims 4 to 6 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the data migration method according to any one of claims 1 to 3 or the data migration method according to any one of claims 4 to 6 is implemented.
Citation Information
Patent Citations
Data migration method and device for heterogeneous database, equipment and medium
CN115454967A
Data sharing method and device for multi-source heterogeneous data, storage medium and terminal
CN116467274A
Data processing method and device, medium and product
CN118152370A
Method and system for sandbox visibility
US20140297587A1
