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

By determining the dependencies and order of the types to be migrated in the database structure migration, and generating the target query statement, the problem of low database migration efficiency is solved, and efficient and safe database structure migration is achieved.

CN119645963BActive Publication Date: 2026-05-29CHINA TELECOM CLOUD TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA TELECOM CLOUD TECH CO LTD
Filing Date
2024-12-06
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies involve large processing volumes, low efficiency, and long migration times during database structure migration.

Method used

By determining the dependencies between the types to be migrated, the migration order is determined, and the target objects are obtained and the target structured query statements are executed in sequence, reducing the overall object tree migration. The initial query statement is transformed using parameters from the source database to generate the target query statement.

Benefits of technology

It effectively reduces data transmission pressure, improves transmission efficiency, shortens migration time, ensures migration security and accuracy, and is suitable for more application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645963B_ABST
    Figure CN119645963B_ABST
Patent Text Reader

Abstract

The application 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 receiving a structure migration instruction of 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 plurality of to-be-migrated types according to a dependency relationship among the plurality of to-be-migrated types; 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 target object execution corresponding to the plurality of to-be-migrated types is completed, 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 parameters of the target database. The method can improve migration efficiency and shorten time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This 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 Technology

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

[0003] In related technologies, when migrating a database structure, the target database obtains the corresponding structure object from the source database and executes the corresponding data statements. Successful execution completes the structure migration. However, this method involves a large amount of data processing, is inefficient, and takes a long time. Summary of the Invention

[0004] Therefore, 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-mentioned technical problems.

[0005] Firstly, this 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 the source database to the target database, determine multiple migration types corresponding to the structure migration instruction;

[0007] Based on the dependencies between the multiple types to be migrated, determine the migration order corresponding to the multiple types to be migrated;

[0008] Based on the migration order, the target object corresponding to each of the migration types is obtained, and the target structured query statement corresponding to the target object is executed until the target objects corresponding to the multiple migration types are executed. The target structured query statement is obtained by processing the 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, obtaining the target object corresponding to each migration type based on the migration order includes:

[0010] Based on the migration order, the target type is determined from the plurality of types to be migrated;

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

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

[0013] If the structural migration instruction includes selection information for the target type, the candidate object is determined as the target object; and / or,

[0014] If the structure migration instruction includes selection information for a subset of candidate objects under the target type, the selected candidate object is determined to be the target object.

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

[0016] Based on the target object, a target processing thread is determined, and the target processing thread corresponds one-to-one with the target object;

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

[0018] In one embodiment, the method for determining the target structured query statement includes:

[0019] Using the preset plugin corresponding to the source database, the initial structured query statement corresponding to the target object is obtained from the source database;

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

[0021] In one embodiment, determining the migration order corresponding to the plurality of migration types based on the dependencies between the plurality of migration types includes:

[0022] Based on the parameters of the source database, determine the structural parameters corresponding to the multiple types to be migrated;

[0023] The dependencies between the multiple types to be migrated are determined based on the structural parameters, and a migration order corresponding to the dependencies is generated.

[0024] Secondly, this application also provides a database structure migration apparatus, which is applied to a target database and includes:

[0025] The receiving module is configured to, in response to receiving a structure migration instruction from the source database to the target database, determine multiple migration types corresponding to the structure migration instruction;

[0026] The determination module is used to determine the migration order corresponding to the multiple types to be migrated based on the dependencies between them.

[0027] An execution module is used to obtain the target object corresponding to each of the migration types based on the migration order, and execute the target structured query statement corresponding to the target object until the target objects corresponding to the multiple migration types are executed. The target structured query statement is obtained by processing the 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, the target type is determined from the plurality of types to be migrated;

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

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

[0032] If the structural migration instruction includes selection information for the target type, the candidate object is determined as the target object; and / or,

[0033] If the structure migration instruction includes selection information for a subset of candidate objects under the target type, the selected candidate object is determined to be the target object.

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

[0035] Based on the target object, a target processing thread is determined, and the target processing thread corresponds one-to-one with the target object;

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

[0037] In one embodiment, the apparatus further includes a target structured query statement determination module, the target structured query statement determination module being further configured to:

[0038] Using the preset plugin corresponding to the source database, the initial structured query statement corresponding to the target object is obtained from the source database;

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

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

[0041] Based on the parameters of the source database, determine the structural parameters corresponding to the multiple types to be migrated;

[0042] The dependencies between the multiple types to be migrated are determined based on the structural parameters, and a migration order corresponding to the dependencies is generated.

[0043] Thirdly, embodiments of this disclosure also provide a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method described in any one of the embodiments of this disclosure.

[0044] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method described in any one of the embodiments of this disclosure.

[0045] Fifthly, embodiments of this disclosure also provide a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method described in any one of the embodiments of this disclosure.

[0046] The aforementioned database structure migration method, apparatus, computer equipment, computer-readable storage medium, and computer program product, upon receiving a structure migration instruction, determine multiple types to be migrated, and based on the dependencies between these types, determine the migration order corresponding to each type. Following this migration order, they retrieve the target object corresponding to each type and execute the corresponding target structured query statement until all target objects for multiple types have been processed, thus completing the database structure migration from the source database to the target database. During the database structure migration process, migrating target objects according to the types to be migrated, rather than migrating the entire object tree, effectively reduces data transmission pressure, improves data transmission efficiency, and significantly shortens the migration time. Determining the migration order based on the dependencies between the types ensures the safety and reliability of the migration, avoiding object creation failures due to disordered migration order. Furthermore, migrating sequentially ensures that if the target object in the source database changes during the migration process, the object being migrated is the changed object, guaranteeing the accuracy of the migrated structure and making it suitable for a wider range of application scenarios. Attached Figure Description

[0047] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a flowchart illustrating a database structure migration method in one embodiment;

[0049] Figure 2 This is a flowchart illustrating how a target structured query statement is determined in one embodiment.

[0050] Figure 3 This is a flowchart illustrating the database structure migration method in another embodiment;

[0051] Figure 4 This is a flowchart illustrating the database structure migration method in another embodiment;

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

[0053] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0055] In one embodiment, such as Figure 1 As shown, a database structure migration method is provided. This embodiment illustrates the method applied to a terminal, but it is understood that the method can also be applied to a server, or to a system including both a terminal and a server, and implemented through 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 the source database to the target database, determine multiple migration types corresponding to the structure migration instruction;

[0057] For example, the structure migration command can be sent to the front-end user. In one example, the front-end user can select the objects and types that need to be migrated and send the structure migration command.

[0058] Determine the multiple types to be migrated corresponding to the structure migration instruction. The types can be database structure types, including but not limited to SCHEMA, TABLE, VIEW, FUNCTION, DB_LINK, etc. The specific types can be determined based on the actual application scenario.

[0059] Step S120: Determine the migration order corresponding to the multiple types to be migrated based on the dependencies between them;

[0060] For example, the migration order of multiple types to be migrated is determined based on the dependencies between them. In one example, different database structures may have dependencies on each other; the current database structure can only be created after the dependent database structure has been created.

[0061] Optionally, the migration order of multiple types to be migrated can be determined. In one example, a type to be migrated later can depend on a type to be migrated earlier, but a type to be migrated earlier cannot depend on a type to be migrated 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. The target structured query statement is obtained by 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, migrations can be performed sequentially 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 one example, if the execution is successful, the object to be migrated can be considered to have been successfully migrated.

[0064] For example, the target structured query statement is generated based on parameters from 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 transformed according to the parameters of the source database to obtain the target structured query statement that conforms to the target database structure.

[0065] In this embodiment, upon receiving a structure migration instruction, multiple migration types are identified. Based on the dependencies between these types, a migration order is determined. Following this order, the target object for each migration type is retrieved, and the corresponding target structured query statement is executed until all target objects for each migration type have been processed, thus completing the migration of the database structure from the source database to the target database. During the database structure migration, target objects are migrated according to their respective migration types, rather than the entire object tree. This effectively reduces data transmission pressure, improves data transmission efficiency, and shortens the migration time. Determining the migration order based on the dependencies between migration types ensures the safety and reliability of the migration, avoiding object creation failures due to disordered migration order. Furthermore, since migration is performed sequentially, if the target object in the source database changes during the migration process, the object being migrated is the changed object, ensuring the accuracy of the migrated structure and making it suitable for a wider range of application scenarios.

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

[0067] Based on the migration order, the target type is determined from the plurality of types to be migrated;

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

[0069] For example, the target type that needs to be migrated now is determined from multiple types to be migrated based on the migration order. In one example, the target type can be determined based on the migration order and the current migration progress.

[0070] For example, candidate objects corresponding to the target type are obtained based on parameters from the source database. In one example, the candidate objects could 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, which can be used to determine the selected candidate object as the target object.

[0072] In this embodiment of the disclosure, when determining the target object, all candidate objects corresponding to the target type are first determined, and then the target object is obtained by filtering according to the structure migration instruction. This enables the target object to be obtained quickly and accurately. At the same time, since the candidate object is determined only when it is the turn of the target type, the real-time performance 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 structural migration instruction includes:

[0074] If the structural migration instruction includes selection information for the target type, the candidate object is determined as the target object; and / or,

[0075] If the structure migration instruction includes selection information for a subset of candidate objects under the target type, the selected candidate object is determined to be the target object.

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

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

[0078] In this embodiment of the disclosure, the target object is determined based on the selection information in the structure migration instruction. This allows for the rapid and accurate identification of the user-selected object to be migrated from the candidate objects, enabling targeted database structure migration. This approach is applicable to 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] Based on the target object, a target processing thread is determined, and the target processing thread corresponds one-to-one with the target object;

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

[0082] For example, a target processing thread is determined based on the target object. In one example, there may be multiple target objects. When determining the target processing thread, a processing thread is assigned to each target object, and there is a one-to-one correspondence between the target processing thread and the target object.

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

[0084] In this embodiment of the disclosure, when executing a target structured query statement, a target processing thread corresponding to each target object is determined. Since the threads are divided according to migration type and a migration order is set, the order in which multiple target objects are executed simultaneously does not affect the success or failure of the structure migration. This enables multiple target objects to be executed and consumed concurrently, effectively shortening the migration time and improving the migration efficiency.

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

[0086] Step S210: Using the preset plugin corresponding to the source database, obtain the initial structured query statement corresponding to the target object from the source database;

[0087] Step S220: The initial structured query statement is transformed according to the parameters of the target database to obtain the target structured query statement.

[0088] For example, a pre-defined plugin is used to retrieve the initial structured query statement corresponding to the target object from the source database. In one example, the initial structured query statement may include a create statement.

[0089] The statement is transformed based on the parameters of the target database. The statement type can be determined according to the database structure type of the target database, and the initial structured query statement is transformed so that the target structured query statement conforms to the database structure of the target database.

[0090] In this embodiment of the disclosure, a preset plugin is invoked to obtain an initial structured query statement and then transformed to obtain a target structured query statement. This allows for the execution of the target structured query statement to perform verification on objects migrated to the target database, ensuring the reliability and accuracy of the database structure migration.

[0091] In one embodiment, determining the migration order corresponding to the plurality of migration types based on the dependencies between the plurality of migration types includes:

[0092] Based on the parameters of the source database, determine the structural parameters corresponding to the multiple types to be migrated;

[0093] The dependencies between the multiple types to be migrated are determined based on the structural parameters, and a migration order corresponding to the dependencies is generated.

[0094] For example, based on the parameters of the source database, the structural parameters corresponding to multiple types to be migrated are determined, and different types can correspond to different structural parameters.

[0095] The dependencies between multiple types to be migrated are determined based on structural parameters, and the migration order corresponding to these dependencies is generated. In one example, the dependencies between different types of types can be determined based on their structural parameters. The dependencies between these types are then obtained based on the structural parameters for each type.

[0096] In this embodiment, structural parameters are determined based on the parameters of the source database, and dependencies are determined based on the structural parameters to obtain the corresponding migration order. This allows the migration order to be set according to the characteristics of different types to be migrated, avoiding the problem of objects failing to be created due to chaotic migration order, ensuring the stability of the migration process, and making it suitable for more application scenarios.

[0097] Figure 3 This is a schematic diagram illustrating a database structure migration method according to an exemplary embodiment, with reference to... Figure 3 As shown, taking Oracle as the source database, after the front-end user selects the objects to be migrated, the data transfer is executed. Following the data transfer instructions, if the leaf node of the migration object tree in the back-end is only specified to the type, it means all objects under that type need to be transferred. When the leaf node of the migration object tree is specified to the schema object, it means all types under that schema and all objects under that type need to be migrated. When the leaf node of the migration object tree is specified to other specific objects, it means only the user-specified objects under that 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, the schema must be created first, the sequence must be created before the table, and other types must be created after the table.

[0098] When the backend receives the migration object tree from the frontend, it can complete it to the type layer. During the completion process, the specific schema objects to be migrated are added to the task_queue (i.e., the target objects corresponding to the type to be migrated, which is SCHEMA) for later use, and the schema value corresponding to each type to be migrated is calculated for later use.

[0099] Figure 4 This is a schematic diagram illustrating a database structure migration process according to an exemplary embodiment, with reference to... Figure 4As shown, the `task_queue` already contains concrete schema objects (target objects). Multiple target processing threads can be called to consume these objects concurrently. When these objects are consumed, the queue is empty, and all threads are waiting for data. At this point, the last thread about to enter the waiting queue puts the next type of data to be processed (i.e., the next type to be migrated in the migration order), such as TABLE, into the `task_queue`. After other threads obtain this type of data, they find the schema information corresponding to that type and put it into the `task_queue`. After other threads obtain this information, they call the source database's preset plugin to get all objects (i.e., candidate objects) under the specified type and schema name. After verifying them with the object selected by the user, they obtain the final object to be migrated (i.e., the target object) and put it into the `task_queue`. At this time, the `task_queue` contains concrete table objects, which is the same situation as when the `task_queue` initially contained concrete schema objects. This completes a full loop. In each loop, all migration objects under the same type are processed in order. After all the types to be migrated have been processed, the database structure migration is complete.

[0100] This embodiment accelerates the entire structure migration process by concurrently constructing, validating, and consuming the migration object tree. Furthermore, during front-end and back-end transmission, it is unnecessary to transmit the complete migration object tree. The space complexity of the migration object tree involved in this embodiment is O(m), while the space complexity of the complete migration object tree is O(nm). Typically, n is much larger than m, thus effectively reducing the data transmission pressure between the front-end and back-end.

[0101] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0102] Based on the same inventive concept, this application also provides a database structure migration apparatus for implementing the database structure migration method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more database structure migration apparatus embodiments provided below can be found in the limitations of the database structure migration method described above, and will not be repeated here.

[0103] In one exemplary embodiment, such as Figure 5 As shown, a database structure migration device 500 is provided. The device is applied to a target database and includes:

[0104] The receiving module 510 is configured to, in response to receiving a structure migration instruction from the source database to the target database, determine multiple migration types corresponding to the structure migration instruction;

[0105] The determination module 520 is used to determine the migration order corresponding to the multiple types to be migrated based on the dependencies between them.

[0106] The execution module 530 is used to obtain the target object corresponding to each of the migration types based on the migration order, and execute the target structured query statement corresponding to the target object until the target objects corresponding to the multiple migration types are executed. The target structured query statement is obtained by processing the 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, the target type is determined from the plurality of types to be migrated;

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

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

[0111] If the structural migration instruction includes selection information for the target type, the candidate object is determined as the target object; and / or,

[0112] If the structure migration instruction includes selection information for a subset of candidate objects under the target type, the selected candidate object is determined to be the target object.

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

[0114] Based on the target object, a target processing thread is determined, and the target processing thread corresponds one-to-one with the target object;

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

[0116] In one embodiment, the apparatus further includes a target structured query statement determination module, the target structured query statement determination module being further configured to:

[0117] Using the preset plugin corresponding to the source database, the initial structured query statement corresponding to the target object is obtained from the source database;

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

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

[0120] Based on the parameters of the source database, determine the structural parameters corresponding to the multiple types to be migrated;

[0121] The dependencies between the multiple types to be migrated are determined based on the structural parameters, and a migration order corresponding to the dependencies is generated.

[0122] Each module in the aforementioned database structure migration device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0123] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The database stores data related to the methods described in this embodiment, such as target objects. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a database structure migration method.

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

[0125] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0126] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

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

[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, data stored, data displayed, 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 the relevant data must comply with relevant regulations.

[0129] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this 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. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0130] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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 embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A database structure migration method, characterized in that, The method is applied to the target database and includes: In response to receiving a structure migration instruction from the source database to the target database, determine multiple migration types corresponding to the structure migration instruction; Based on the dependencies between the multiple types to be migrated, determine the migration order corresponding to the multiple types to be migrated; Based on the migration order, the target object corresponding to each of the migration types is obtained, and the target structured query statement corresponding to the target object is executed until the target objects corresponding to the multiple migration types are executed. The target structured query statement is obtained by processing the initial structured query statement corresponding to the target object in the source database according to the parameters of the target database. The step of determining the migration order corresponding to the plurality of migration types based on the dependencies between them includes: Based on the parameters of the source database, determine the structural parameters corresponding to the multiple types to be migrated; The dependencies between the multiple types to be migrated are determined based on the structural parameters, and a migration order corresponding to the dependencies is generated; The step of obtaining the target object corresponding to each migration type based on the migration order includes: Based on the migration order and the current migration progress, determine the target type that needs to be migrated from the plurality of types to be migrated; Based on the parameters of the source database, candidate objects corresponding to the target type are obtained in real time, and the target object is determined from the candidate objects according to the selection information included in the structure migration instruction. If the target object in the source database changes during the migration process, the object at the time of migration is the changed object.

2. The method according to claim 1, characterized in that, The step of determining the target object from the candidate objects based on the selection information included in the structure migration instruction includes: If the structural migration instruction includes selection information for the target type, the candidate object is determined as the target object; and / or, If the structure migration instruction includes selection information for a subset of candidate objects under the target type, the selected candidate object is determined to be the target object.

3. The method according to claim 1, characterized in that, The execution of the target structured query statement corresponding to the target object includes: Based on the target object, a target processing thread is determined, and the target processing thread corresponds one-to-one with the target object; The target processing thread is invoked to execute the target structured query statement corresponding to the target object.

4. The method according to claim 1, characterized in that, The methods for determining the target structured query statement include: Using the preset plugin corresponding to the source database, the initial structured query statement corresponding to the target object is obtained from the source database; The initial structured query statement is transformed according to the parameters of the target database to obtain the target structured query statement.

5. A database structure migration device, characterized in that, The device is applied to the target database and includes: The receiving module is configured to, in response to receiving a structure migration instruction from the source database to the target database, determine multiple migration types corresponding to the structure migration instruction; The determination module is used to determine the migration order corresponding to the multiple types to be migrated based on the dependencies between them. An execution module is used to obtain the target object corresponding to each of the migration types based on the migration order, and execute the target structured query statement corresponding to the target object until the target objects corresponding to the multiple migration types are executed. The target structured query statement is obtained by processing the initial structured query statement corresponding to the target object in the source database according to the parameters of the target database. The determining module is further configured to: Based on the parameters of the source database, determine the structural parameters corresponding to the multiple types to be migrated; The dependencies between the multiple types to be migrated are determined based on the structural parameters, and a migration order corresponding to the dependencies is generated; The execution module is further configured to: Based on the migration order and the current migration progress, determine the target type that needs to be migrated from the plurality of types to be migrated; Based on the parameters of the source database, candidate objects corresponding to the target type are obtained in real time, and the target object is determined from the candidate objects according to the selection information included in the structure migration instruction. If the target object in the source database changes during the migration process, the object at the time of migration is the changed object.

6. The apparatus according to claim 5, characterized in that, The execution module is further configured to: If the structural migration instruction includes selection information for the target type, the candidate object is determined as the target object; and / or, If the structure migration instruction includes selection information for a subset of candidate objects under the target type, the selected candidate object is determined to be the target object.

7. The apparatus according to claim 5, characterized in that, The execution module is further configured to: Based on the target object, a target processing thread is determined, and the target processing thread corresponds one-to-one with the target object; The target processing thread is invoked to execute the target structured query statement corresponding to the target object.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.

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

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