Method, device, electronic equipment and storage medium for offsite database merging

By preprocessing and merging geographically dispersed databases, the problems of server resource waste and data isolation were solved, achieving efficient database merging and system stability, and ensuring the accuracy of data queries and the high availability of the system.

CN119903109BActive Publication Date: 2025-11-28QIAN JIN NETWORK INFORMATION TECH SHANGHAI LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411964618.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-11-28
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

In database clusters located in different regions, there are issues of wasted server resources, data isolation, and complex interactions, resulting in insufficient system stability and response speed, and a lack of effective solutions.

Method used

By preprocessing multiple databases to be merged to ensure consistency in data table structure and storage method, adding data source identifiers, selecting the master database and uploading it to the cloud server, merging regional databases step by step, resolving primary key conflicts using merged primary key value fields, and configuring a backup database to ensure system stability.

Benefits of technology

This achieves efficient utilization of server resources, shortens merging time, saves labor costs, ensures the accuracy of data queries and the high availability of the system, and reduces the risk of system crashes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903109B_ABST
    Figure CN119903109B_ABST
Patent Text Reader

Abstract

The application discloses a method for off-site database merging, comprising: preprocessing a plurality of databases to be merged to make the table structure and data storage mode of data tables in the plurality of databases to be merged consistent; adding a data source identifier to all data tables of the plurality of databases to be merged; selecting one database meeting a condition as a total database from the plurality of databases to be merged after preprocessing and adding the data source identifier, and setting the total database on a cloud server; setting the remaining regional databases to the cloud server according to a predetermined batch or a predetermined order and merging the regional databases with the total database to form a cloud database; and setting a headquarter database to the cloud server and merging the headquarter database with the cloud database to complete the merging.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, and particularly relates to a method and device for merging databases in different places, electronic equipment, computer readable storage medium and computer program product. BACKGROUND

[0002] For enterprises that need to store a large amount of data or process a large amount of data, it is often necessary to set up databases in different regions or different regions, and sometimes it is also necessary to set up independently deployed servers to run these databases. With the development of business, the number of databases and the data stored in each database will continue to increase, forming a database cluster. For example, a commercial system has nearly 30 sets of independently deployed databases in nearly 30 regions, which is a waste of server resources.

[0003] With the passage of time, the number of servers that need to be deployed in different places is increasing, not only there is a waste of server resources, more importantly, there is a different degree of data isolation between the databases of the servers in different regions, and the data interaction process between the databases in different places is complex, and the data request response is slow. If there are too many databases, the data interaction, statistics and other operations of the database cluster are extremely unfavorable, and there is a risk of system collapse. In order to maintain the normal operation of the multi-region database, the resource cost and time cost required to maintain the normal operation of the multi-region database is increasing, and there is still a lack of clear and effective solution to improve the operation and maintenance of the multi-region database. SUMMARY

[0004] Therefore, the embodiment of the present application provides a method for merging databases in different places, comprising the following steps: preprocessing a plurality of databases to be merged to make the table structure and data storage mode of the data tables in the plurality of databases to be merged consistent, wherein the plurality of databases to be merged comprise a headquarters database and a plurality of regional databases, and the headquarters database has a higher level than the regional databases; adding a data source identifier to all the data tables in the plurality of databases to be merged, wherein the data source identifier is used to mark the original database to which the data table belongs; selecting one database meeting the conditions from the plurality of databases to be merged as a total database, and setting the total database on a cloud server, wherein the total database belongs to the regional databases; setting the remaining regional databases to the cloud server according to a predetermined batch or a predetermined order and merging the regional databases with the total database to form a database on the cloud; and setting the headquarters database to the cloud server and merging the headquarters database with the database on the cloud to complete the merging of the databases; wherein, in the preprocessing process, if there are data tables with primary key conflicts, a merging primary key value field is added to each of the data tables with primary key conflicts, the merging primary key value field stores the primary key value of the data table after merging, and the merging primary key value field is used as a query condition together with the data source identifier in a data query task involving the primary key to locate the required data table according to the target merging primary key value and the target data source identifier in the merged database.

[0005] Optionally, in the preprocessing process, if there are data tables with seed conflicts, the method further comprises: increasing the primary key interval corresponding to the data tables with seed conflicts to prevent seed conflicts during database merging.

[0006] Optionally, the method further comprises: before or during the database merging, updating the starting value of the primary key self-increment interval of the data table to be merged according to the preset numerical range corresponding to the region where the original database to which the data table to be merged belongs, to prevent seed conflicts during the merging.

[0007] Optionally, in the database merging process, if there is a database without a primary key table, the method further comprises: adding a primary key table to the database without a primary key table; and setting the starting value of the primary key self-increment interval of the added primary key table according to the preset numerical range corresponding to the region where the database without a primary key table is located.

[0008] Optionally, before the database merging, the method further comprises: modifying the replication relationship between the headquarters database and the local databases before the database merging, so that the replication relationship between the headquarters database and the local databases is consistent after the database merging, wherein the data to be replicated meets the replication condition of any one of the headquarters database and the local databases, and the data is replicated.

[0009] Optionally, after the merging of the databases is completed, the cloud-based database synchronizes data to the merged regional databases or the headquarters database based on the data source field, and configures the merged databases as backup databases, so that the backup databases can be switched to in case of failure of the cloud-based database.

[0010] Optionally, the databases are merged one by one in the order of data size from small to large, so as to reduce the risk of large-scale data conflicts and improve the merging efficiency.

[0011] The application further includes an apparatus for merging databases in different places, comprising: a data preprocessing module for preprocessing a plurality of databases to be merged, so that the table structure and data storage mode of the data tables in the plurality of databases to be merged are consistent, wherein the plurality of databases to be merged include a headquarters database and a plurality of regional databases, and the headquarters database has a higher level than the regional databases; a data source adding module for adding a data source identifier to all data tables of the plurality of databases to be merged, the data source identifier being used to mark the original database to which the data table belongs; a total database setting module for selecting one database meeting the conditions from the plurality of databases to be merged after preprocessing and adding the data source identifier as a total database, and setting the total database on a cloud server, wherein the total database belongs to a regional database; a regional database merging module for setting the remaining regional databases to the cloud server in a predetermined batch or a predetermined order and merging the regional databases with the total database to form a cloud-based database; and a headquarters database merging module for setting the headquarters database to the cloud server and merging the headquarters database with the cloud-based database to complete the merging of the databases; wherein, in the preprocessing process, if there are data tables with primary key conflicts, a merging primary key value field is added to each of the data tables with primary key conflicts, the merging primary key value field storing the primary key value of the data table after merging, and the merging primary key value field being used as a query condition together with the data source identifier in a data query task involving the primary key, so as to locate the required data table according to the target merging primary key value and the target data source identifier in the merging of the databases.

[0012] The application further includes an electronic device, comprising a processor and a memory storing computer program instructions; the electronic device implements the method according to any one of the preceding embodiments when executing the computer program instructions.

[0013] The application further includes a computer readable storage medium, characterized in that the computer readable storage medium stores computer program instructions, and the computer program instructions are executed by a processor to implement the method according to any one of the preceding embodiments.

[0014] The application further comprises a computer program product characterized in that it comprises computer program instructions which, when executed by a processor, implement the method according to any one of the preceding.

[0015] The application provides an electronic device, which comprises a processor and a memory storing computer program instructions; the processor implements the steps of the method according to the above when executing the computer program instructions.

[0016] By using the embodiments of the application, the server data dispersed in different regions can be combined into a total server in a short time, and the server resource occupation is greatly reduced. Moreover, the application scheme has little change on the existing data as a whole, which not only shortens the time consumption of server combination, but also saves the labor cost. The application uses the method of adding a data source field and the like, which can effectively avoid the problem of data disorder. When the combination processing is performed, the modified data is also written into the combined server, so that when the total database has a problem, the regional data can be switched to in time, and the system risk is reduced. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the application, the following briefly introduces the drawings in the embodiments of the application.

[0018] Figure 1 is a flow block diagram of the method for off-site database combination of the embodiments of the application.

[0019] Figure 2 is a structural schematic diagram of the device for off-site database combination of the embodiments of the application.

[0020] Figure 3 is a schematic diagram of an electronic device for implementing the method for off-site database combination of the embodiments of the application. DETAILED DESCRIPTION

[0021] The principles and spirits of the application will be described below with reference to a plurality of exemplary embodiments. It should be understood that the purpose of providing these embodiments is to make the principles and spirits of the application clearer and more thorough, and to enable those skilled in the art to better understand and implement the principles and spirits of the application. The exemplary embodiments provided herein are only part of the embodiments of the application, rather than all the embodiments. Based on the embodiments herein, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the application.

[0022] Embodiments of this application relate to terminal devices and / or servers. Those skilled in the art will understand that embodiments of this application can be implemented as a system, apparatus, device, method, computer-readable storage medium, or computer program product. Therefore, this disclosure can be specifically implemented in at least one of the following forms: entirely hardware, entirely software, or a combination of hardware and software. According to embodiments of this application, this application claims protection for a method, apparatus, electronic device, computer-readable storage medium, and computer program product for merging remote databases.

[0023] In this document, terms such as first, second, and third are used only to distinguish one entity (or operation) from another, and are not intended to require or imply any order or relationship between these entities (or operations).

[0024] In databases, table structure is typically the fundamental component used to organize and store data. The database table structure defines how data is stored and how it is related to each other. Typically, each table has a unique primary key to uniquely identify each row of data in the table. Each column of a table defines a field, and each field has a specific data type. The data type determines the type and format of data that a field can store. The primary function of the primary key is to ensure the uniqueness of the data.

[0025] When databases are first established, for ease of management and access, they are typically set up near the data's location based on its generation and usage. For example, a database might be set up on a server in Beijing to store user data for local Beijing users. To expand business to multiple different regions, one or more databases might be established in those regions. However, as the amount of data increases, multiple databases separated in different regions become inconvenient to maintain and manage, and also hinder data access.

[0026] Based on this, this application proposes a method for merging geographically distributed databases, wherein the multiple databases can be located in different regions. Figure 1 A flowchart illustrating a method for merging geographically dispersed databases according to an embodiment of this application is shown. The method includes the following steps:

[0027] In step S101: Preprocess the multiple databases to be merged to make the table structure and data storage method of the data tables in the multiple databases to be merged consistent. The multiple databases to be merged include a headquarters database and multiple regional databases, with the headquarters database having a higher level than the regional databases.

[0028] In step S102: Add a data source identifier to all data tables of multiple databases to be merged. The data source identifier is used to mark the original database to which the data table belongs.

[0029] In step S103: in the plurality of databases to be merged after preprocessing and adding data source identification, one database meeting the conditions is selected as a total database, and the total database is set on a cloud server, wherein the total database belongs to a regional database.

[0030] In step S104: the remaining regional databases are respectively set on the cloud server according to a predetermined batch or a predetermined order and merged with the total database to form a cloud database.

[0031] In step S105: the headquarters database is set on the cloud server and merged with the cloud database to complete the merging of the databases. In the preprocessing process, if a data table with a primary key conflict exists, a merged primary key value field is added to each of the plurality of data tables with the primary key conflict, the merged primary key value field stores the primary key value of the data table after merging, and the merged primary key value field is used as a query condition together with the data source identification in a data query task involving the primary key to locate the required data table according to the target merged primary key value and the target data source identification in the merged database.

[0032] The application ensures that the table structures and data storage modes of the databases are consistent through preprocessing of the plurality of databases to be merged, solves the merging problem caused by inconsistent database structures, can effectively track the data source through the addition of the data source identification field, and facilitates data analysis and management in the later stage; at the same time, the merged primary key value field is used to solve the primary key conflict problem, ensuring accurate data query and accurate positioning of the data in the merging process.

[0033] By using the embodiments of the application, a database of one region is uploaded to a cloud server, a total database is established on the cloud server based on the database, and then other databases are uploaded to the cloud server one by one and merged with the total database, so that the server data scattered in different regions can be merged into a total server in a short time, and the server resource occupation is greatly reduced. The phased merging mode ensures the controllability and flexibility of the merging operation and reduces the risk in the merging process. Moreover, the application scheme has small overall data changes to the existing system, which not only shortens the time consumption of server merging, but also saves labor costs.

[0034] In some embodiments, in the preprocessing process, if a data table with a seed conflict exists, the method further includes: increasing the primary key interval corresponding to the data table with the seed conflict to prevent seed conflicts during database merging.

[0035] By increasing the primary key interval, seed conflicts can be effectively avoided, and it is ensured that the primary key values of each table are not repeated during database merging, thereby avoiding data errors caused by primary key conflicts and ensuring the consistency and integrity of the data.

[0036] In some embodiments, the method further comprises: before or during the database merging, updating the starting value of the primary key self-increment interval of the data table to be merged according to the preset numerical range corresponding to the region where the original database to which the data table to be merged belongs, so that seed conflict does not occur during merging.

[0037] Adjusting the starting value of the primary key self-increment interval before or during merging ensures that the merged database does not have seed conflict, this preventive measure provides more flexible adjustment space for the merging process, avoids merging failure caused by primary key conflict, and improves the efficiency and accuracy of merging.

[0038] In some embodiments, during the database merging process, if a database without a primary key table appears, the method further comprises: adding a primary key table in the database without a primary key table; and setting the starting value of the primary key self-increment interval of the added primary key table according to the preset numerical range corresponding to the region where the database without a primary key table is located.

[0039] For a primary key table, adding a primary key table and setting the starting value of the self-increment interval according to the original region not only ensures the integrity and uniqueness of the data table, but also avoids data operation errors caused by the lack of a primary key field, further enhancing the stability and query efficiency of the database.

[0040] In some embodiments, before merging the databases, further comprising: modifying the replication relationship between the headquarters database and the local database, so that after merging the databases, the replication relationship between the headquarters database and the local database is consistent, wherein the data to be replicated satisfies the replication condition of any one of the headquarters database and the local database, and the data is replicated.

[0041] Modifying the replication relationship between the headquarters database and the local database ensures that the replication rules of the headquarters and local databases remain consistent after merging, which unifies the data synchronization rules between databases, ensures seamless data flow between different databases, and improves data consistency, avoiding conflicts and errors that may occur during synchronization.

[0042] In some embodiments, after the merging is completed, the cloud database synchronizes data to the merged regional database or the headquarters database based on the data source field, and configures the merged database as a standby database, so that in the event of a failure of the cloud database, the standby database can be used.

[0043] After merging the databases, the total database synchronizes data to the merged database based on the data source field, ensuring data consistency between all databases and improving data integrity. Through this synchronization mechanism, even if the total database fails, accurate data transmission between databases can still be ensured.

[0044] In some embodiments, after the merging is completed, the merged database is configured as a standby database environment by an automated tool or script, which can quickly switch to the standby database when the total database fails to ensure business continuity.

[0045] The merged database is configured as a standby database environment using an automated tool or script, which can quickly switch when the total database fails, ensuring business continuity. This mechanism reduces manual intervention, improves fault response speed, and ensures high availability and fault tolerance of the system.

[0046] In some embodiments, after the total database resumes normal operation, data is synchronized back to the merged database, and traffic is switched back to the total database to achieve data consistency after failure recovery.

[0047] After the total database resumes normal operation, data is synchronized back to the merged database, and traffic is switched back to the total database, ensuring data consistency and smooth operation of the system after recovery. This mechanism enables seamless data recovery and business transition, improving system stability.

[0048] In some embodiments, the databases are merged one by one from small to large according to data size to reduce the risk of large-scale data conflicts and improve merging efficiency.

[0049] Merging databases one by one according to data size can effectively avoid conflicts and performance bottlenecks during large-scale data merging, reducing the risk of merging and improving merging efficiency. This merging strategy not only gradually accumulates experience and optimizes the merging process, but also ensures the smooth operation of each merging operation, avoiding system crashes or processing delays caused by excessive data volume. Using the embodiments of the present application, even if the table structures of databases in different regions are different, the merging can be accurate, fast, and without omission. Moreover, online services can run in order without being affected during and after merging.

[0050] In some embodiments, the database tables of the plurality of databases are adjusted, including:

[0051] In step S301: For the database tables with missing or incorrect structures, the database tables are supplemented or corrected.

[0052] In step S302: For the abandoned database tables, they are marked and no longer uploaded to the cloud server.

[0053] In step S303: The tables generated by the stored procedures are checked, and tables that need to be deleted and rebuilt are selected. These tables are not uploaded, and the tables are recreated when the stored procedures are re-run.

[0054] To ensure the uniformity and integrity of the regional database tables, the tables used by each region need to be standardized. Specifically, missing data will be carefully checked and filled in to ensure that the database table structures of all regions remain consistent. For tables that have been abandoned, they will be explicitly marked and decided not to be migrated to the cloud to avoid unnecessary waste of resources.

[0055] For tables generated by stored procedures, if they need to be deleted and recreated, they will not be migrated either. After the system goes online, these tables can be regenerated by running the stored procedures again. In some embodiments, to better track and identify the source of the data, a field named "sourceBranch" can be added to all tables. This field will be used to identify which database the data comes from, making it easier to write data from the online database back to the offline database.

[0056] During the addition of this field, the value of the field will be matched according to the current region to ensure that the source of the data is clear and explicit. In this way, not only can the traceability of the data be improved, but it also helps to be more efficient and accurate in subsequent data processing and analysis.

[0057] In one specific embodiment, to ensure the uniformity and integrity of the regional database tables, the tables used by each region need to be standardized. During this process, missing data will be carefully checked and filled in to ensure that the database table structures of all regions remain consistent. For tables that have been abandoned, they will be explicitly marked and decided not to be migrated to the cloud to avoid unnecessary waste of resources.

[0058] For tables generated by stored procedures, if they need to be deleted and recreated, they will not be migrated either. After the system goes online, these tables can be regenerated by running the stored procedures again. In addition, to better track and identify the source of the data, a field named "sourceBranch" can be added to all tables. This field will be used to identify which database the data comes from, making it easier to write data from the online database back to the offline database.

[0059] During the addition of this field, the value of the field will be matched according to the current region to ensure that the source of the data is clear and explicit. In this way, not only can the traceability of the data be improved, but it also helps to be more efficient and accurate in subsequent data processing and analysis.

[0060] In some embodiments, the stored procedures of multiple databases are adjusted, including: comparing the stored procedures of each region and the headquarters, correcting the differences and missing stored procedures; for stored procedures that are no longer needed in the total database, offline processing is performed; for stored procedures involving the creation of tables, the logic of creating tables for these stored procedures is compared and made consistent.

[0061] To optimize and unify database operations across regions, a detailed comparison of stored procedures between regions and headquarters (HQ) will be conducted. During this process, attention will be focused on those stored procedures that have differences or are missing, and they will be supplemented and corrected one by one. For stored procedures that are no longer needed or have become obsolete, they will be handled offline to ensure the efficiency and accuracy of database operation.

[0062] At the same time, all existing stored procedures will be thoroughly investigated to assess whether they need to be modified or optimized. In particular, for the logic of creating tables in stored procedures, we will focus on checking whether key fields such as xx, HQ, EC, etc. are consistent in all table creation logic. This is to prevent errors in program queries due to missing fields. Through this series of comparison, supplementation, correction and investigation, the integrity and consistency of the database will be ensured, providing strong support for the stable operation of the business.

[0063] In a specific embodiment, to optimize and unify database operations across regions, a detailed comparison of stored procedures between regions and headquarters (HQ) will be conducted. During this process, attention will be focused on those stored procedures that have differences or are missing, and they will be supplemented and corrected one by one. For stored procedures that are no longer needed or have become obsolete, they will be handled offline to ensure the efficiency and accuracy of database operation.

[0064] At the same time, all existing stored procedures will be thoroughly investigated to assess whether they need to be modified or optimized. In particular, for the logic of creating tables in stored procedures, we will focus on checking whether key fields such as xx, HQ, EC, etc. are consistent in all table creation logic. This is to prevent errors in program queries due to missing fields. Through this series of comparison, supplementation, correction and investigation, the integrity and consistency of the database will be ensured, providing strong support for the stable operation of the business.

[0065] In a specific embodiment, the modification of the primary key conflict table can include:

[0066] The first: a new field will be added, which is specifically used to store the existing primary key value. This measure aims to solve the primary key conflict problem while preserving the original primary key information. At the same time, a data source field will also be added, and the value of the data source field in the database of different regions will be different. In order to ensure the accuracy and efficiency of the query, the new field and the data tag (sourceBranch) information will be used as query conditions in all queries involving the primary key. In this way, even if there is a primary key conflict, the required data can still be accurately located by combining the new field and branch information. This modification not only solves the potential primary key conflict problem, but also improves the flexibility and accuracy of data query.

[0067] Second: for the primary key conflict table, based on the primary key conflict table associated with the ID interval increase update, to ensure that the library will not have a primary key conflict; let the administrator of the merged database set the non-conflict auto-increment interval start value according to the region in advance. For example, the primary keys of Table 1 and Table 2 are both catid, the values of catid of Table 1 are 1 to 20, and the values of catid of Table 2 are 12 to 40. If the two tables are merged into the same database, it will inevitably lead to primary key conflict. Then the primary key value of Table 1 can be increased by 100000, and the primary key value of Table 2 can be increased by 200000, so that the primary key values of the two tables are completely different, avoiding primary key conflict.

[0068] In some embodiments, the process of merging databases is from small to large according to the size of the database. First, merge the database with small data volume, which is convenient for early operation and does not cause large area influence, and can quickly accumulate experience to make the subsequent large database merging more smooth.

[0069] In some embodiments, the table in the current database is not configured with an index, and the number of rows of the table data exceeds 100000 after merging, then an index is added to the table after merging.

[0070] Before the merging of databases begins, databases in different regions may need to interact with the headquarters database, such as copying data from the headquarters database to the local database. Different databases and the headquarters may have different replication rules.

[0071] In a specific embodiment, during the library merging process, the replication relationship between the headquarters (hq) and each region needs to be carefully adjusted. After the library merging is completed, the original source library replication rule will no longer apply, and the replication rule needs to be updated to be based on the or relationship of the two database replication conditions. After merging, all data uses a unified replication rule. This adjustment aims to ensure that data can flow accurately and efficiently in the new architecture, thereby meeting the needs of business operations. By optimizing the replication relationship, the performance and stability of the database can be further improved, providing strong support for the continuous development of the business.

[0072] In some embodiments, further comprising: after the data of the plurality of databases is merged into the total database, the total database synchronizes data to the database based on the data source field.

[0073] In some embodiments, further comprising updating and preserving the database, including: setting up a standby database environment, keeping synchronization with the online database for backup; when the total database fails, switching the traffic to the database through an automated tool or script to ensure business continuity; starting the data synchronization program to synchronize the normal data of the total database to the database to ensure data consistency; after completing data synchronization, switching the business traffic back to the total library to restore normal operation.

[0074] Through the above operations, after the database merging, the total database is increased, and the data of the merged database is synchronized according to the data source mark, and the merged database is used as a backup database. In this way, even if the total database of the cloud server is out of order, a total database can be quickly merged again for use.

[0075] In some embodiments, the present application further includes an apparatus for off-site database merging, as shown in the accompanying drawings, the apparatus comprises: Figure 2 As shown in the accompanying drawings, the apparatus comprises:

[0076] The data preprocessing module 201 is configured to preprocess a plurality of to-be-merged databases, so that the table structure and data storage mode of the data tables in the plurality of to-be-merged databases are consistent, wherein the plurality of to-be-merged databases comprise a headquarter database and a plurality of regional databases, and the level of the headquarter database is higher than that of the regional databases;

[0077] The data source adding module 202 is configured to add a data source mark in all data tables of the plurality of to-be-merged databases, and the data source mark is used to mark the original database to which the data table belongs;

[0078] The total database setting module 203 is configured to select one database meeting the conditions from the plurality of to-be-merged databases after preprocessing and adding the data source mark as a total database, and set the total database on a cloud server, wherein the total database belongs to a regional database;

[0079] The regional database merging module 204 is configured to set the remaining regional databases to the cloud server according to a predetermined batch or a predetermined order respectively and merge with the total database to form a cloud database;

[0080] The headquarter database merging module 205 is configured to set the headquarter database to the cloud server and merge with the cloud database to complete the database merging; wherein,

[0081] In the preprocessing process, if there are data tables with primary key conflicts, a merging primary key value field is added in each of the data tables with primary key conflicts, the merging primary key value field stores the primary key value of the data table after merging, and the merging primary key value field is used as a query condition together with the data source mark in a data query task involving the primary key, so as to locate the required data table according to the target merging primary key value and the target data source mark in the merged database.

[0082] The electronic device in the embodiment of the present application can be a user terminal device, a server, other computing devices, or a cloud server. Figure 3A hardware structure schematic diagram of an electronic device of an embodiment of the present application is shown, which can include a processor 601 and a memory 602 storing computer program instructions, and the processor 601 implements the flow or function of the method of any of the above embodiments when executing the computer program instructions.

[0083] Specifically, the processor 601 can include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or can be configured to implement one or more integrated circuits of the embodiments of the present application. The memory 602 can include a mass storage for data or instructions. For example, the memory 602 can be at least one of a hard disk drive (HDD), a read-only memory (ROM), a random access memory (RAM), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, a universal serial bus (USB) drive, or other physical / tangible memory storage device. In another example, the memory 602 can include removable or non-removable (or fixed) media. In yet another example, the memory 602 can be internal or external to the integrated gateway disaster recovery device. The memory 602 can be a non-volatile solid-state memory. In other words, the memory 602 generally includes a tangible (non-transitory) computer-readable storage medium (such as a memory device) encoded with computer-executable instructions that, when executed (by one or more processors), perform the operations described in the method of the embodiments of the present application. The processor 601 implements the flow or function of the method of any of the above embodiments by reading and executing the computer program instructions stored in the memory 602.

[0084] In one example, Figure 3The electronic device shown can also include a communication interface 603 and a bus 610. Among them, the processor 601, the memory 602, the communication interface 603 are connected through the bus 610 and complete the communication between each other. The communication interface 603 is mainly used to realize the communication between the modules, devices, units and / or equipment in the embodiments of the application. The bus 610 includes hardware, software or both, which can couple the components of the online data traffic billing device to each other. For example, the bus can include at least one of the following: an accelerated graphics port (AGP) or other graphics bus, an enhanced industry standard architecture (EISA) bus, a front side bus (FSB), a hyper transport (HT) interconnect, an industry standard architecture (ISA) bus, an infiniband interconnect, a low pin count (LPC) bus, a memory bus, a micro channel architecture (MCA) bus, a peripheral component interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a serial advanced technology attachment (SATA) bus, a video electronics standards association local (VLB) bus or other suitable bus. The bus 610 can include one or more buses. Although the embodiments of the application describe or show a specific bus, any suitable bus or interconnection method can be considered by the embodiments of the application.

[0085] In combination with the method in the above embodiments, the embodiments of the application further provide a computer readable storage medium, which has stored thereon computer program instructions, and the computer program instructions are executed by a processor to implement the flow or function of any of the methods in the above embodiments.

[0086] In addition, the embodiments of the application also provide a computer program product, which has stored thereon computer program instructions, and the computer program instructions are executed by a processor to implement the flow or function of any of the methods in the above embodiments.

[0087] The flowcharts and / or block diagrams of the methods, devices, systems and computer program products of the embodiments of the application are described above as examples, and the related aspects are described. It should be understood that each block in the flowchart and / or block diagram can be implemented by computer program instructions, or by special hardware that performs specified functions or actions, or by a combination of special hardware and computer instructions. For example, these computer program instructions can be provided to a processor of a general purpose computer, a special purpose computer or other programmable data processing apparatus to form a machine, so that the instructions executed by the processor enable the implementation of the functions / actions specified in each block or combination of blocks in the flowchart and / or block diagram. Such a processor can be a general purpose processor, a special purpose processor, a special application processor or a field programmable logic circuit.

[0088] The functional blocks shown in the structural block diagram of the embodiments of the present application can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a functional card, and the like; when implemented in software, it is a program or a code segment used to perform the required tasks. The program or code segment can be stored in a memory or transmitted through a data signal carried in a carrier wave over a transmission medium or a communication link. The code segment can be downloaded via a computer network, such as the Internet, an intranet, and the like.

[0089] It should be noted that the present application is not limited to the specific configurations and processes described above or shown in the drawings. The above is merely a specific implementation of the present application, and those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the described systems, devices, modules or units can refer to the corresponding processes in the method embodiments, which need not be described again. It should be understood that the protection scope of the present application is not limited thereto, and any skilled person in the art can think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be covered within the protection scope of the present application.

Claims

1. A method for offsite database merge, the method comprising: The method comprises the following steps: Preprocessing a plurality of to-be-merged databases to make the table structure and data storage mode of the data tables in the plurality of to-be-merged databases consistent, wherein the plurality of to-be-merged databases comprise a headquarters database and a plurality of regional databases, and the headquarters database has a higher level than the regional databases; Adding a data source identifier to all data tables in the plurality of to-be-merged databases, wherein the data source identifier is used to mark the original database to which the data table belongs; Selecting one database meeting the conditions from the plurality of to-be-merged databases as a total database, and setting the total database on a cloud server, wherein the total database belongs to a regional database; Setting the remaining regional databases to the cloud server in a predetermined order and merging the regional databases with the total database to form a cloud database; Setting the headquarters database to the cloud server and merging the headquarters database with the cloud database to complete the merging of the databases; and In the preprocessing process, if there are data tables having primary key conflicts, a merging primary key value field is added to each of the data tables having primary key conflicts, the merging primary key value field stores the primary key value of the data table after merging, and the merging primary key value field is used as a query condition together with the data source identifier in a data query task involving the primary key to locate the required data table according to the target merging primary key value and the target data source identifier in the merged database.

2. The method of claim 1, wherein, In the preprocessing process, the method further comprises: If there are data tables having seed conflicts, increasing the primary key interval of the data tables having seed conflicts to avoid seed conflicts during database merging; and / or If there is a database without a primary key table, adding a primary key table to the database without the primary key table, and setting the starting value of the primary key self-increment interval of the added primary key table according to a preset numerical range corresponding to the region where the database without the primary key table is located.

3. The method of claim 1, wherein, The method further comprises: Before or during the merging of the databases, updating the starting value of the primary key self-increment interval of the data table to be merged according to a preset numerical range corresponding to the region where the original database to which the data table to be merged belongs, to avoid seed conflicts during the merging.

4. The method of claim 1, wherein, Before merging the databases, the method further comprises: Modifying the replication relationship between the headquarters database and the local databases to make the replication relationship between the headquarters database and the local databases consistent after the databases are merged, wherein the data to be replicated meets the replication condition of any one of the headquarters database and the local databases, and the data is replicated.

5. The method of claim 1, wherein, The predetermined order comprises an order from small to large according to the size of the database to be merged.

6. The method of claim 1, wherein, After the merging of the databases is completed, the cloud database synchronizes data to the merged regional databases or the headquarters database based on the data source field, and configures the merged databases as backup databases to switch to the backup databases for use when the cloud database fails.

7. An apparatus for remote database merge, the apparatus comprising: The method comprises: The data preprocessing module is configured to preprocess a plurality of databases to be merged so as to make the table structure and data storage mode of data tables in the plurality of databases to be merged consistent, wherein the plurality of databases to be merged include a headquarter database and a plurality of regional databases, and the headquarter database has a higher level than the regional databases. The data source adding module is configured to add a data source identifier in all data tables of the plurality of databases to be merged, and the data source identifier is used to mark the original database to which the data table belongs. The total database setting module is configured to select one database meeting a condition from the plurality of databases to be merged as a total database, and set the total database on a cloud server, wherein the total database belongs to a regional database. The regional database merging module is configured to set the remaining regional databases to the cloud server according to a predetermined batch or a predetermined order, and merge the regional databases with the total database to form a cloud database. The headquarter database merging module is configured to set the headquarter database to the cloud server, and merge the headquarter database with the cloud database to complete the merging of the databases. In the preprocessing process, if there are data tables with primary key conflicts, a merging primary key value field is added in each of the data tables with primary key conflicts, the merging primary key value field stores the primary key value of the data table after merging, and the merging primary key value field is used as a query condition together with the data source identifier in a data query task involving the primary key, so as to locate a required data table according to a target merging primary key value and a target data source identifier in the merged database.

8. An electronic device, comprising: The electronic device includes a processor and a memory storing computer program instructions; and the electronic device implements the method according to any one of claims 1-6 when executing the computer program instructions.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions, and the computer program instructions are executed by the processor to implement the method according to any one of claims 1-6.

10. A computer program product, characterised in that, The computer program instructions are executed by the processor to implement the method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Quality management transversal integration system and method

    CN101458782A

  • Cross-machine-room data synchronization system, method and device and electronic device

    CN108573006A