Database structure migration method and device, computer equipment, readable storage medium and program product

By determining the type and migration order to be migrated in the database structure migration and executing the target structure query statement, the problem of inefficient migration of database structures in the existing technology is solved, and more efficient data transmission and a more reliable migration process are achieved.

CN119645963AActive Publication Date: 2025-03-18CHINA TELECOM CLOUD TECH CO LTD

Patent Information

Application Number
CN202411791428.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-03-18
Estimated Expiration
2044-12-06

AI Technical Summary

Technical Problem

During the migration of database structures, the existing technology is inefficient and the data processing volume is large, resulting in a long migration time.

Method used

By receiving structural migration instructions in the target database, determine the types to be migrated and determine the migration order based on the dependencies between these types. Then, each target object of the type to be migrated is obtained based on the migration order, and a target structured query statement is executed until all target objects of the type to be migrated are executed.

Benefits of technology

This method effectively reduces the pressure of data transmission, improves data transmission efficiency, shortens the time-consuming process of structure migration, and ensures the security and reliability of migration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645963A_ABST
    Figure CN119645963A_ABST
Patent Text Reader

Abstract

The invention relates to a database structure migration method and device, computer equipment, a computer readable storage medium and a computer program product. The method is applied to a target database and comprises the following steps: in response to a received structure migration instruction from a source database to the target database, determining a plurality of to-be-migrated types corresponding to the structure migration instruction; determining a migration sequence corresponding to the to-be-migrated types according to the dependency relationship among the to-be-migrated types; and based on the migration sequence, obtaining a target object corresponding to each to-be-migrated type, and executing a target structured query statement corresponding to the target object until execution of the target objects corresponding to the to-be-migrated types is completed, the target structured query statement is obtained by processing an initial structured query statement corresponding to the target object in the source database according to the parameters of the target database. The method can improve the migration efficiency and shorten the time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a database structure migration method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] Database structure migration refers to the process of transferring the structure of a database (such as tables, views, indexes, etc.) to another database or database instance. It is usually used for database upgrades, platform migration, or synchronization between different environments (such as development, testing, and production).

[0003] In the related art, when performing database structure migration, the target database obtains the structure object corresponding to the source database and executes the corresponding data statement to successfully complete the structure migration. However, this method has a large amount of data processing during the migration process, low efficiency, and a long migration time. Summary of the invention

[0004] Based on this, it is necessary to provide a database structure migration method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve efficiency and shorten time in response to the above technical problems.

[0005] In a first aspect, the present application provides a database structure migration method, which is applied to a target database and includes:

[0006] In response to receiving a structure migration instruction from a source database to the target database, determining a plurality of to-be-migrated types corresponding to the structure migration instruction;

[0007] Determining a migration order corresponding to the multiple types to be migrated according to the dependency relationship between the multiple types to be migrated;

[0008] Based on the migration order, a target object corresponding to each type to be migrated is obtained, and a target structured query statement corresponding to the target object is executed until the target objects corresponding to the multiple types to be migrated are executed, wherein the target structured query statement is obtained after processing an initial structured query statement corresponding to the target object in the source database according to the parameters of the target database.

[0009] In one embodiment, acquiring the target object corresponding to each type to be migrated based on the migration order includes:

[0010] Based on the migration order, determining a target type from the multiple types to be migrated;

[0011] According to the parameters of the source database, candidate objects corresponding to the target type are acquired, and according to the structure migration instruction, a target object is determined from the candidate objects.

[0012] In one embodiment, determining the target object from the candidate objects according to the structure migration instruction includes:

[0013] In a case where the structure migration instruction includes selection information for the target type, determining the candidate object as the target object; and / or,

[0014] In a case where the structure migration instruction includes selection information for some candidate objects under the target type, the selected candidate objects are determined as target objects.

[0015] In one embodiment, executing the target structured query statement corresponding to the target object includes:

[0016] Determine a target processing thread according to the target object, wherein the target processing thread corresponds to the target object one by one;

[0017] The target processing thread is called to execute the target structured query statement corresponding to the target object.

[0018] In one embodiment, the target structured query statement is determined by:

[0019] Using a preset plug-in corresponding to the source database, an initial structured query statement corresponding to the target object is obtained from the source database;

[0020] The initial structured query statement is converted according to the parameters of the target database to obtain a target structured query statement.

[0021] In one embodiment, determining the migration order corresponding to the multiple types to be migrated according to the dependency relationship between the multiple types to be migrated includes:

[0022] Determining structural parameters corresponding to the multiple types to be migrated according to the parameters of the source database;

[0023] Dependencies between the multiple types to be migrated are determined according to the structural parameters, and a migration sequence corresponding to the dependencies is generated.

[0024] In a second aspect, the present application further provides a database structure migration device, which is applied to a target database and includes:

[0025] A receiving module, configured to, in response to receiving a structure migration instruction from a source database to a target database, determine a plurality of to-be-migrated types corresponding to the structure migration instruction;

[0026] A determination module, configured to determine a migration order corresponding to the multiple types to be migrated according to dependencies between the multiple types to be migrated;

[0027] An execution module is used to obtain a target object corresponding to each type to be migrated based on the migration order, and execute a target structured query statement corresponding to the target object until the target objects corresponding to the multiple types to be migrated are executed, wherein the target structured query statement is obtained after processing an initial structured query statement corresponding to the target object in the source database according to the parameters of the target database.

[0028] In one embodiment, the execution module is further configured to:

[0029] Based on the migration order, determining a target type from the multiple types to be migrated;

[0030] According to the parameters of the source database, candidate objects corresponding to the target type are acquired, and according to the structure migration instruction, a target object is determined from the candidate objects.

[0031] In one embodiment, the execution module is further configured to:

[0032] In a case where the structure migration instruction includes selection information for the target type, determining the candidate object as the target object; and / or,

[0033] In a case where the structure migration instruction includes selection information for some candidate objects under the target type, the selected candidate objects are determined as target objects.

[0034] In one embodiment, the execution module is further configured to:

[0035] Determine a target processing thread according to the target object, wherein the target processing thread corresponds to the target object one by one;

[0036] The target processing thread is called to execute the target structured query statement corresponding to the target object.

[0037] In one embodiment, the device further includes a target structured query statement determination module, and the target structured query statement determination module is further used to:

[0038] Using a preset plug-in corresponding to the source database, an initial structured query statement corresponding to the target object is obtained from the source database;

[0039] The initial structured query statement is converted according to the parameters of the target database to obtain a target structured query statement.

[0040] In one embodiment, the determining module is further configured to:

[0041] Determining structural parameters corresponding to the multiple types to be migrated according to the parameters of the source database;

[0042] Dependencies between the multiple types to be migrated are determined according to the structural parameters, and a migration sequence corresponding to the dependencies is generated.

[0043] In a third aspect, an embodiment of the present disclosure further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of any one of the methods in the embodiments of the present disclosure are implemented.

[0044] In a fourth aspect, the embodiments of the present disclosure further provide a computer-readable storage medium, wherein a computer program is stored thereon, and when the computer program is executed by a processor, the steps of any one of the methods in the embodiments of the present disclosure are implemented.

[0045] In a fifth aspect, the embodiments of the present disclosure further provide a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the steps of any one of the methods in the embodiments of the present disclosure are implemented.

[0046] The above-mentioned database structure migration method, device, computer equipment, computer-readable storage medium and computer program product, when receiving a structure migration instruction, determine multiple types to be migrated, and determine the migration order corresponding to the multiple types to be migrated according to the dependency relationship between the multiple types to be migrated, obtain the corresponding target object under each type to be migrated according to the migration order, and execute the corresponding target structured query statement until the target objects corresponding to the multiple types to be migrated are all executed, and the migration of the database structure from the source database to the target database is completed. In the process of database structure migration, the target object is migrated according to the type to be migrated, rather than the entire object tree as a whole, which effectively reduces the pressure of data transmission, improves the efficiency of data transmission, and effectively shortens the time-consuming process of structure migration; the migration order is determined according to the dependency relationship between the types to be migrated, which ensures the security and reliability of the migration and avoids the problem of object creation failure caused by confusion in the migration order; and the migration is carried out in sequence. If the target object in the source database changes during the migration process, the object at the time of migration is the changed object, which ensures the accuracy of the structure after migration and is suitable for more application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions 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 related drawings can be obtained based on these drawings without paying creative work.

[0048] Figure 1 A schematic diagram of a process of migrating a database structure in one embodiment;

[0049] Figure 2 A schematic diagram of a flow chart of a method for determining a target structured query statement in one embodiment;

[0050] Figure 3 A schematic diagram of a flow chart of a database structure migration method in another embodiment;

[0051] Figure 4 A schematic diagram of a flow chart of a database structure migration method in another embodiment;

[0052] Figure 5 A structural block diagram of a database structure migration device in one embodiment;

[0053] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] In one embodiment, Figure 1 As shown, a method for migrating a database structure is provided. This embodiment uses the method applied to a terminal as an example for illustration. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method is applied to a target database, including:

[0056] Step S110, in response to receiving a structure migration instruction from a source database to the target database, determining a plurality of to-be-migrated types corresponding to the structure migration instruction;

[0057] Exemplarily, the structure migration instruction can be sent by the front-end user. In one example, the front-end user can check the objects and types that need to be migrated and send the structure migration instruction.

[0058] Determine multiple types to be migrated corresponding to the structure migration instruction. The type may be a type of database structure, including but not limited to SCHEMA, TABLE, VIEW, FUNCTION, DB_LINK, etc., which may be determined according to actual application scenarios.

[0059] Step S120, determining a migration order corresponding to the multiple types to be migrated according to the dependency relationship between the multiple types to be migrated;

[0060] Exemplarily, the migration order corresponding to the multiple types to be migrated is determined according to the dependency relationship between the multiple types to be migrated. In one example, there may be a dependency relationship between different database structures, and the current database structure can only be created after the dependent database structure is created.

[0061] Optionally, a migration order corresponding to a plurality of types to be migrated is determined. In one example, a type to be migrated that is migrated later may depend on a type to be migrated that is migrated earlier, and a type to be migrated that is migrated earlier may not depend on a type to be migrated that is created later.

[0062] Step S130, based on the migration order, obtain the target object corresponding to each of the types to be migrated, and execute the target structured query statement corresponding to the target object, until the target objects corresponding to the multiple types to be migrated are executed, wherein the target structured query statement is obtained after processing the initial structured query statement corresponding to the target object in the source database according to the parameters of the target database.

[0063] Optionally, the migration is performed in sequence according to the migration order. During the migration process, the target object corresponding to the current type to be migrated is obtained, and the target structured query statement corresponding to the target object is executed. In an example, if the execution is successful, it can be considered that the object to be migrated has been successfully migrated.

[0064] Exemplarily, the target structured query statement is generated according to the parameters of the target database. In one example, the initial structured query statement corresponding to the target object in the source database is obtained, and the initial structured query statement is converted according to the parameters of the source database to obtain the target structured query statement that conforms to the structure of the target database.

[0065] In the disclosed embodiment, upon receiving a structural migration instruction, multiple types to be migrated are determined, and according to the dependency relationship between the multiple types to be migrated, the migration order corresponding to the multiple types to be migrated is determined. According to the migration order, the corresponding target object under each type to be migrated is obtained, and the corresponding target structured query statement is executed until the target objects corresponding to the multiple types to be migrated are all executed, thereby completing the migration of the database structure from the source database to the target database. In the process of database structure migration, the target object is migrated according to the type to be migrated, rather than the entire object tree as a whole, which effectively reduces the pressure of data transmission, improves the efficiency of data transmission, and effectively shortens the time consumption of the structural migration process; the migration order is determined according to the dependency relationship between the types to be migrated, which ensures the security and reliability of the migration and avoids the problem of object creation failure caused by confusion in the migration order; and the migration is performed in sequence. If the target object in the source database is changed during the migration process, the object at the time of migration is the changed object, which ensures the accuracy of the structure after migration and is suitable for more application scenarios.

[0066] In one embodiment, acquiring the target object corresponding to each type to be migrated based on the migration order includes:

[0067] Based on the migration order, determining a target type from the multiple types to be migrated;

[0068] According to the parameters of the source database, candidate objects corresponding to the target type are acquired, and according to the structure migration instruction, a target object is determined from the candidate objects.

[0069] Exemplarily, the target type that needs to be migrated currently is determined from a plurality of types to be migrated according to the migration order. In one example, the target type can be determined according to the migration order and the current migration progress.

[0070] Exemplarily, according to the parameters of the source database, the candidate objects corresponding to the target type are obtained. In one example, the candidate objects may be all objects corresponding to the target type in the source database.

[0071] Optionally, the target object is determined from the candidate objects according to the structure migration instruction. In one example, the structure migration instruction includes selection information, and the selected candidate object can be determined as the target object according to the selection information.

[0072] In the disclosed embodiment, when determining the target object, all candidate objects corresponding to the target type are first determined, and then the target object is obtained by screening according to the structure migration instruction, so that the target object can be obtained quickly and accurately. At the same time, since the candidate object is determined when it is the turn of the target type, the real-time and accuracy of the candidate object can be guaranteed, thereby ensuring the reliability of the structure migration.

[0073] In one embodiment, determining the target object from the candidate objects according to the structure migration instruction includes:

[0074] In a case where the structure migration instruction includes selection information for the target type, determining the candidate object as the target object; and / or,

[0075] In a case where the structure migration instruction includes selection information for some candidate objects under the target type, the selected candidate objects are determined as target objects.

[0076] Exemplarily, when the structure migration instruction includes selection information for the target type, it can be considered that the front-end user directly selected the target type when sending the structure migration instruction, and all objects corresponding to the target type need to be migrated to the target database. At this time, the candidate object is determined to be the target object.

[0077] Optionally, when the structure migration instruction includes selection information for some candidate objects under the target type, it can be considered that the front-end user has selected some objects under the target type when sending the structure migration instruction, and the selected objects need to be migrated to the target database. At this time, the selected candidate objects are determined to be the target objects.

[0078] The disclosed embodiment determines the target object according to the selection information in the structure migration instruction, can quickly and accurately determine the object selected by the user to be migrated from the candidate objects, and perform database structure migration in a targeted manner, which is suitable for more application scenarios and effectively shortens the migration time.

[0079] In one embodiment, executing the target structured query statement corresponding to the target object includes:

[0080] Determine a target processing thread according to the target object, wherein the target processing thread corresponds to the target object one by one;

[0081] The target processing thread is called to execute the target structured query statement corresponding to the target object.

[0082] Exemplarily, the target processing thread is determined according to the target object. In one example, the target object may include multiple ones, and when determining the target processing thread, a processing thread is allocated to each target object, and the target processing thread corresponds to the target object one by one.

[0083] Optionally, the target processing thread is called to execute the target structured query statement. In one example, when the target processing thread includes multiple processing threads, the multiple processing threads can be executed concurrently.

[0084] In the disclosed embodiment, when executing a target structured query statement, a target processing thread corresponding to a target object is determined. Since the target objects are divided according to migration types and a migration order is set, the order of executing multiple target objects simultaneously does not affect the success of the structure migration. Thus, concurrent execution and consumption of multiple target objects can be achieved, effectively shortening the migration time and improving the migration efficiency.

[0085] In one embodiment, Figure 2 As shown, the method for determining the target structured query statement includes:

[0086] Step S210, using a preset plug-in corresponding to the source database, obtaining an initial structured query statement corresponding to the target object from the source database;

[0087] Step S220: converting the initial structured query statement according to the parameters of the target database to obtain a target structured query statement.

[0088] Exemplarily, the initial structured query statement corresponding to the target object is obtained from the source database using a preset plug-in. In one example, the initial structured query statement may include a create statement.

[0089] The statement conversion is performed according to the parameters of the target database, wherein the corresponding statement type can be determined according to the database structure type of the target database, and the initial structured query statement is converted, and the target structured query statement obtained after the conversion conforms to the database structure of the target database.

[0090] In the disclosed embodiment, a preset plug-in is called to obtain an initial structured query statement, and converted to obtain a target structured query statement, so that the objects migrated to the target database can be verified by executing the target structured query statement, thereby ensuring the reliability and accuracy of the database structure migration.

[0091] In one embodiment, determining the migration order corresponding to the multiple types to be migrated according to the dependency relationship between the multiple types to be migrated includes:

[0092] Determining structural parameters corresponding to the multiple types to be migrated according to the parameters of the source database;

[0093] Dependencies between the multiple types to be migrated are determined according to the structural parameters, and a migration sequence corresponding to the dependencies is generated.

[0094] Exemplarily, structural parameters corresponding to a plurality of types to be migrated are determined according to parameters of the source database, and different types may correspond to different structural parameters.

[0095] Determine the dependency relationship between multiple types to be migrated according to the structural parameters, and generate a migration order corresponding to the dependency relationship. In one example, it is possible to determine whether a type to be migrated depends on other structural types and what structural types it depends on according to different types of structural parameters, and obtain the dependency relationship between multiple types to be migrated according to the structural parameters corresponding to each type to be migrated.

[0096] In the disclosed embodiment, structural parameters are determined according to parameters of a source database, and dependencies are determined according to the structural parameters to obtain a corresponding migration order, so that the migration order can be set according to the characteristics of different types to be migrated, thereby avoiding the problem of being unable to create objects due to confusion in the migration order, ensuring the stability of the migration process, and being suitable for more application scenarios.

[0097] Figure 3 is a schematic diagram of a database structure migration method according to an exemplary embodiment, referring to Figure 3 As shown in the figure, taking Oracle as the source database, the front-end user selects the migration object and sends the data transfer execution. If the leaf nodes of the migration object tree that follow the data transfer instruction to the back-end are only accurate to the type, it means that all objects under this type need to be transferred. When the leaf nodes of the migration object tree are accurate to the schema object, it means that all types under the schema and all objects under the type need to be migrated. When the leaf nodes of the migration object tree are accurate to other specific objects, it means that only the user-specified objects under this type need to be transferred. When migrating to the target database, due to the dependencies between objects of different types to be migrated, the creation order of various types needs to be strictly managed. For example, Schema must be created first, Sequence must be created before Table, and other types must be created after Table.

[0098] When the backend obtains the migration object tree sent by the frontend, it can complete it to the type layer. During the completion process, the specific schema objects to be migrated are queued into task_queue (that is, the type to be migrated is SCHEMA and the corresponding target object) for subsequent use, and the schema values ​​corresponding to each type to be migrated are counted for subsequent use.

[0099] Figure 4 A schematic diagram of a database structure migration process according to an exemplary embodiment is shown. Figure 4As shown, there are specific schema objects (target objects) in task_queue, and multiple target processing threads can be called for concurrent consumption. When these objects are consumed, the queue is empty and all threads are waiting for data. At this time, the last thread that is about to enter the waiting state puts the next type of data to be processed (i.e., the next type to be migrated in the migration sequence) into task_queue, such as TABLE. After other threads obtain this type of data, they find the schema information corresponding to the type to be migrated and put it into task_queue. After other threads obtain this information, they will call the preset plug-in of the source database to get all objects under the specified type and schema name (i.e., candidate objects), and after reviewing with the object selected by the user, they get the final object to be migrated (i.e., target object) and put it into task_queue. At this time, task_queue contains specific table objects, which is the same as the initial task_queue, which contains specific schema objects. A complete cycle is completed. In each cycle, all migration objects of the same type are processed in sequence. After all types to be migrated are executed, the database structure migration is completed.

[0100] Through this embodiment, the concurrent construction, verification, and consumption of the migration object tree accelerates the entire structure migration process. In addition, when transmitting between the front-end and the back-end, there is no need to transmit the complete migration object tree. The space complexity of the migration object tree involved in this embodiment is O(m), and the space complexity of the complete migration object tree is O(nm). Usually, n is much larger than m, which effectively reduces the pressure of data transmission between the front-end and the back-end.

[0101] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0102] Based on the same inventive concept, the embodiment of the present application also provides a database structure migration device for implementing the database structure migration method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more database structure migration device embodiments provided below can refer to the limitations of the database structure migration method above, and will not be repeated here.

[0103] In an exemplary embodiment, Figure 5 As shown, a database structure migration device 500 is provided, and the device is applied to a target database, comprising:

[0104] A receiving module 510 is configured to, in response to receiving a structure migration instruction from a source database to a target database, determine a plurality of to-be-migrated types corresponding to the structure migration instruction;

[0105] A determination module 520, configured to determine a migration order corresponding to the multiple types to be migrated according to the dependency relationship between the multiple types to be migrated;

[0106] An execution module 530 is used to obtain, based on the migration order, a target object corresponding to each type to be migrated, and execute a target structured query statement corresponding to the target object until the target objects corresponding to the multiple types to be migrated are executed, wherein the target structured query statement is obtained by processing an initial structured query statement corresponding to the target object in the source database according to the parameters of the target database.

[0107] In one embodiment, the execution module is further configured to:

[0108] Based on the migration order, determining a target type from the multiple types to be migrated;

[0109] According to the parameters of the source database, candidate objects corresponding to the target type are acquired, and according to the structure migration instruction, a target object is determined from the candidate objects.

[0110] In one embodiment, the execution module is further configured to:

[0111] In a case where the structure migration instruction includes selection information for the target type, determining the candidate object as the target object; and / or,

[0112] In a case where the structure migration instruction includes selection information for some candidate objects under the target type, the selected candidate objects are determined as target objects.

[0113] In one embodiment, the execution module is further configured to:

[0114] Determine a target processing thread according to the target object, wherein the target processing thread corresponds to the target object one by one;

[0115] The target processing thread is called to execute the target structured query statement corresponding to the target object.

[0116] In one embodiment, the device further includes a target structured query statement determination module, and the target structured query statement determination module is further used to:

[0117] Using a preset plug-in corresponding to the source database, an initial structured query statement corresponding to the target object is obtained from the source database;

[0118] The initial structured query statement is converted according to the parameters of the target database to obtain a target structured query statement.

[0119] In one embodiment, the determining module is further configured to:

[0120] Determining structural parameters corresponding to the multiple types to be migrated according to the parameters of the source database;

[0121] Dependencies between the multiple types to be migrated are determined according to the structural parameters, and a migration sequence corresponding to the dependencies is generated.

[0122] Each module in the above-mentioned database structure migration device can be implemented in whole or in part by software, hardware or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0123] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 6As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the target object and other data involved in the method described in this embodiment. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a database structure migration method is implemented.

[0124] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0125] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0126] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0127] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0128] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0129] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0130] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0131] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A database structure migration method, characterized in that: The method is applied to a target database, comprising: In response to receiving a structure migration instruction from a source database to the target database, determining a plurality of to-be-migrated types corresponding to the structure migration instruction; Determining a migration order corresponding to the multiple types to be migrated according to the dependency relationship between the multiple types to be migrated; Based on the migration order, a target object corresponding to each type to be migrated is obtained, and a target structured query statement corresponding to the target object is executed until the target objects corresponding to the multiple types to be migrated are executed, wherein the target structured query statement is obtained after processing an initial structured query statement corresponding to the target object in the source database according to the parameters of the target database.

2. The method according to claim 1, characterized in that The acquiring, based on the migration order, a target object corresponding to each type to be migrated includes: Based on the migration order, determining a target type from the multiple types to be migrated; According to the parameters of the source database, candidate objects corresponding to the target type are acquired, and according to the structure migration instruction, a target object is determined from the candidate objects.

3. The method according to claim 2, characterized in that The step of determining a target object from the candidate objects according to the structure migration instruction includes: In a case where the structure migration instruction includes selection information for the target type, determining the candidate object as the target object; and / or, In a case where the structure migration instruction includes selection information for some candidate objects under the target type, the selected candidate objects are determined as target objects.

4. The method according to claim 2, characterized in that: The executing the target structured query statement corresponding to the target object includes: Determine a target processing thread according to the target object, wherein the target processing thread corresponds to the target object one by one; The target processing thread is called to execute the target structured query statement corresponding to the target object.

5. The method according to claim 1, characterized in that The method of determining the target structured query statement includes: Using a preset plug-in corresponding to the source database, an initial structured query statement corresponding to the target object is obtained from the source database; The initial structured query statement is converted according to the parameters of the target database to obtain a target structured query statement.

6. The method according to claim 1, characterized in that The determining, according to the dependency relationship between the multiple types to be migrated, the migration order corresponding to the multiple types to be migrated includes: Determining structural parameters corresponding to the multiple types to be migrated according to the parameters of the source database; Dependencies between the multiple types to be migrated are determined according to the structural parameters, and a migration sequence corresponding to the dependencies is generated.

7. A database structure migration device, characterized in that: The device is applied to a target database, comprising: A receiving module, configured to, in response to receiving a structure migration instruction from a source database to a target database, determine a plurality of to-be-migrated types corresponding to the structure migration instruction; A determination module, configured to determine a migration order corresponding to the multiple types to be migrated according to dependencies between the multiple types to be migrated; An execution module is used to obtain a target object corresponding to each type to be migrated based on the migration order, and execute a target structured query statement corresponding to the target object until the target objects corresponding to the multiple types to be migrated are executed, wherein the target structured query statement is obtained after processing an initial structured query statement corresponding to the target object in the source database according to the parameters of the target database.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Data migration method and device, server and storage medium

    CN108509556A

  • Database migration evaluation method and device, storage medium and computer equipment

    CN111258989A

  • Concurrent migration method and device of database structure, equipment and storage medium

    CN115543966A

  • Database structure migration method and device, equipment and storage medium

    CN116028466A

  • Data migration method and device and computer equipment

    CN116894024A

Cited By

  • Heterogeneous database table building method and device, equipment, storage medium and program product

    CN121277933A

  • Data processing method and device, computer equipment, readable storage medium and program product

    CN121560970A

  • Database structure migration method, apparatus, computer device, readable storage medium and program product

    WO2026118955A1