A method and system for migrating sub-libraries and sub-tables supporting heterogeneous data

By unloading and reorganizing the data to be migrated into the target table format, calculating the partition key value and loading it into the target sub-database and sub-table, the efficiency and consistency problems of heterogeneous data migration are solved, and the large-scale information system is transformed into a distributed system. Reliable data migration of your architecture.

CN113946565BActive Publication Date: 2024-09-03CHINA CONSTRUCTION BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111277218.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2024-09-03
Estimated Expiration
2041-10-29

AI Technical Summary

Technical Problem

The existing technology lacks an efficient shard database and table migration solution, especially when there are differences between the processor architecture, operating system kernel, character set encoding, data table structure and data distribution method and the target shard database and shard table, it is difficult to Achieve efficient and consistent migration of heterogeneous data.

Method used

By unloading the data to be migrated into formatted data files, obtain the target table parameters, reorganize the data records, calculate the partition key value and write it into the data file, determine the sub-table number, and finally load the data file into the target sub-database sub-table. This method includes data unloading, reorganization, table processing and data loading modules, and is suitable for various traditional centralized databases.

Benefits of technology

It realizes the efficient and consistent migration of massive data from traditional centralized databases to sub-database and sub-table database systems, provides reliable data guarantee for large-scale information application systems to switch to distributed architecture, and has strong versatility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113946565B
    Figure CN113946565B
Patent Text Reader

Abstract

The present invention relates to the technical field of database management and maintenance and automatic programming, and in particular to a method and system for sub-library and sub-table migration that supports heterogeneous data. The method and system reorganize various data records in a data file into migration records corresponding to a target table according to table parameters, and use partition key values ​​to calculate sub-table numbers and obtain corresponding sub-library numbers. The method is adaptable to a variety of existing traditional centralized databases, and can efficiently and consistently migrate heterogeneous data to target sub-library and sub-table databases, providing reliable data guarantee for switching application systems to distributed architectures, and has great significance for the evolution of large-scale information systems to distributed architectures.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database management and maintenance and automatic program design, and in particular to a sub-library and sub-table migration method and system supporting heterogeneous data. Background Art

[0002] As time goes by and the business volume of large-scale information application systems grows, the amount of data is getting larger and larger. The storage pressure and high concurrent access pressure of traditional centralized databases are also increasing. In order to improve the external data service capabilities of the data persistence layer of the application system, it is necessary to adopt the technology of sub-library and sub-table. Sub-library and sub-table means that there are multiple database server nodes, each database service node is a sub-library, and the sub-library is identified by the sub-library number. Each sub-library has multiple data tables with the same table structure. Each data table is a sub-table, which is identified by the sub-table number. The table name of the sub-table ends with the sub-table number of a fixed length as the table name, and the sub-table numbers contained in each sub-library are not repeated. Each sub-table contains a partition key column. The partition key value of a data record can be determined by certain rules to determine the sub-table number where the data record is located. The sub-table number can be further determined according to the sub-library sub-table mapping relationship. The rule for determining the sub-table number by the partition key is fixed, which is called the partition rule. Generally, according to the distribution of the partition key value, the modulus, hashing and other algorithms are selected to distribute the data as evenly as possible in each sub-table.

[0003] In order to complete the data migration of sub-libraries and sub-tables, the original centralized database data is usually read to determine the data to be migrated is located in the target sub-library and sub-table number, and then the data is written to the target sub-library and sub-table. This solution can better complete the migration of isomorphic data in sub-libraries and sub-tables, especially when the only difference between the original centralized database and the target sub-library and sub-table is that the original single table is horizontally split into multiple sub-tables, and the original data table must have a partition key column. However, for the migration of heterogeneous data, for example, when there are differences in processor architecture, operating system kernel, character set encoding, data table structure, and data distribution method with the target sub-library and sub-table database, the existing technology lacks an efficient sub-library and sub-table migration solution. Summary of the invention

[0004] In order to address the deficiencies in the prior art, the present invention proposes a method and system for supporting the migration of heterogeneous data into sharded libraries and tables. The method and system can adapt to a variety of existing traditional centralized databases, efficiently and consistently migrate heterogeneous data to target sharded library and table databases, and provide reliable data guarantees for the application system to switch to a distributed architecture. This is of great significance to the evolution of large-scale information systems to a distributed architecture.

[0005] To achieve the above objectives, the technical solutions adopted by the present invention include:

[0006] A method for migrating sharded databases and tables supporting heterogeneous data, characterized by comprising:

[0007] S1. Unloading the data to be migrated into one or more data files, wherein the data files contain a number of formatted data records, and the formatted data records have the same data record length and data column length;

[0008] S2. Obtain table parameters corresponding to the target table, wherein the table parameters include data file attribute information corresponding to the target table, target table format information, and data file-to-target table mapping information;

[0009] S3. Reorganize each data record in the data file into a migration record corresponding to the target table according to the table parameters;

[0010] S4. Obtain the corresponding partition key value according to the index key value and partition key index type of the migration record;

[0011] S5. Insert the partition key value into the migration record, use the partition key value to calculate the sub-table number, write the sub-table number into the data file to obtain a target table file containing the migration record and the sub-table number;

[0012] S6. Determine the sub-library number to which the target table file belongs according to the sub-library number, and load the target table file into the sub-table with the same sub-table number under the sub-library corresponding to the sub-library number.

[0013] Furthermore, the step S1 further includes:

[0014] When the volume of a single data file exceeds the system limit, the data to be migrated is unloaded into multiple data files, and the multiple data files have the same file name structure and file name prefix.

[0015] Furthermore, the step S1 further includes:

[0016] Verify that the data file contains the partition key column;

[0017] When the data file includes a partition key column, a partition key index is created using the partition key column, wherein the partition key index includes a partition key value;

[0018] When the data file does not contain a partition key column, the external partition key column corresponding to the primary key of the data file is determined according to the foreign key reference relationship between the tables of the data to be migrated, and the partition key index is created using the external partition key column.

[0019] Furthermore, the data file attribute information includes the name of the data file to be migrated, the data record length, the partition key index column name and the partition key index type; the target table format information includes the character set encoding, the column names of each column of the target table, the target table data type, the target table record length and the SQL function; the data file corresponding to the target table mapping information includes the position, length and encoding format of each column and index key value of the target table in the data to be migrated.

[0020] Furthermore, the step S3 includes the following sub-steps:

[0021] S31, determining the data file to be processed according to the name of the data file to be migrated in the data file attribute information;

[0022] S32, parsing the data file according to the data record length, and obtaining the corresponding index key value mapping relationship according to the partition key index column name matching;

[0023] S33. Obtain the index key value from the formatted data record of the data file using the character set encoding according to the index key value mapping relationship.

[0024] Further, the calculating the sub-table number using the partition key value includes:

[0025] Check whether the partition key value corresponds to the partition key index type;

[0026] When the partition key value corresponds to the partition key index type, the partition key value is used to calculate the shard table number according to the preset partition rule;

[0027] When the partition key value does not correspond to the partition key index type, the corresponding partition key value is retrieved according to the partition key index type, and the corresponding partition key value is used to calculate the shard table number according to the preset partition rule.

[0028] Furthermore, loading the target table file into a sub-table with the same sub-table number under a sub-library corresponding to the sub-library number includes loading the target table file into an Oracle database sub-library sub-table, and / or loading the target table file into a general relational database sub-library sub-table.

[0029] The present invention also relates to a sub-library and sub-table migration system supporting heterogeneous data, which is characterized by comprising:

[0030] A data unloading module is used to unload the data to be migrated into one or more data files;

[0031] A data file reorganization module is used to reorganize each data record in the data file into a migration record corresponding to the target table;

[0032] The partition table processing module is used to obtain the partition key value and use the partition key value to calculate the partition table number to obtain the target table file;

[0033] The data loading module is used to load the target table file into the corresponding sub-library and sub-table.

[0034] The present invention also relates to a computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and the computer program implements the above method when executed by a processor.

[0035] The present invention also relates to an electronic device, characterized in that it comprises a processor and a memory;

[0036] The memory is used to store the data to be migrated and table parameters;

[0037] The processor is used to execute the above method by calling the data to be migrated and the table parameters.

[0038] The beneficial effects of the present invention are:

[0039] By adopting the sub-library and sub-table migration method and system supporting heterogeneous data described in the present invention, massive data of the traditional centralized database can be efficiently and consistently migrated to the sub-library and sub-table database system, providing reliable data guarantee for the switch of large-scale information application systems to distributed architecture. It can adapt to a variety of existing traditional centralized databases, and can efficiently and consistently migrate heterogeneous data to the target sub-library and sub-table database, providing reliable data guarantee for the switch of application systems to distributed architecture. It is of great significance to the migration of massive data involved in the evolution of large-scale information systems to distributed architecture, and has strong versatility. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 The figure is a flow chart of the method for migrating heterogeneous data in separate libraries and tables supported by the present invention.

[0041] Figure 2 The schematic diagram of the structure of the sub-library and sub-table migration system supporting heterogeneous data of the present invention is shown. DETAILED DESCRIPTION

[0042] In order to more clearly understand the content of the present invention, it will be described in detail with reference to the drawings and embodiments.

[0043] The first aspect of the present invention relates to a process of steps as follows Figure 1 The sharding migration method that supports heterogeneous data includes:

[0044] S1. Unload the data to be migrated into one or more data files, wherein the data files contain several formatted data records, and the formatted data records have the same data record length and data column length; when the volume of a single data file exceeds the system limit, unload the data to be migrated into multiple data files, wherein the multiple data files have the same file name structure and file name prefix, and can preferably end with a file number, and together form a group of formatted data files. Further, for the generated data, it should also be checked whether it contains a partition key column. When the data file contains a partition key column, the partition key column is used to create a partition key index, and the partition key index contains a partition key value; when the data file does not contain a partition key column, the external partition key column corresponding to the primary key of the data file is determined according to the foreign key reference relationship between the tables of the data to be migrated, and the partition key index is created using the external partition key column. This data unloading step unloads each data table of the original centralized library (the library of the data to be migrated) into a formatted data file, and the content of the data file is a formatted data record, each record is of a fixed length, and the columns contained in each record are also of a fixed length and are arranged in a fixed order. The number of bytes of each record multiplied by the number of records is the data file size.

[0045] S2. Obtain the table parameters corresponding to the target table, wherein the table parameters include the data file attribute information corresponding to the target table, the target table format information, and the data file corresponding to the target table mapping information. Among them, the data file attribute information (the first set of configuration parameters) includes the name of the data file to be migrated, the data record length, the partition key index column name, and the partition key index type; the target table format information (the second set of configuration parameters) includes the character set encoding, the column name of each column of the target table, the target table data type, the target table record length, and the SQL function; the data file corresponding to the target table mapping information (the third set of configuration parameters) includes the position, length, and encoding format of each column and index key value of the target table in the data to be migrated. Determine the source data file (data to be migrated) for processing based on the data file name in the first set of configuration parameters. If the data file name contains wildcards, all matching data files are processed in sequence.

[0046] S3. Reorganize each data record in the data file into the migration record of the corresponding target table according to the table parameters, specifically including the steps S31. Determine the data file to be processed according to the name of the data file to be migrated in the data file attribute information; S32. Parse the data file according to the data record length, and obtain the corresponding index key value mapping relationship according to the partition key index column name matching; S33. Obtain the index key value from the formatted data record of the data file using the character set encoding according to the index key value mapping relationship. Read the source data file, parse each data record according to the record length in the first set of configuration parameters, obtain the mapping relationship between the index key column value in the source data record in the third set of configuration parameters according to the index key column name in each set of configuration parameters, and obtain the original index key value from the data record through the mapping relationship and the character set encoding in the second set of configuration parameters.

[0047] S4. Obtain the corresponding partition key value according to the index key value and partition key index type of the migration record, especially check whether the partition key value corresponds to the partition key index type. When the partition key value corresponds to the partition key index type, use the partition key value to calculate the sub-table number according to the preset partitioning rules; when the partition key value does not correspond to the partition key index type, retrieve the corresponding partition key value according to the partition key index type, and use the corresponding partition key value to calculate the sub-table number according to the preset partitioning rules. Obtain the partition key value according to the original index key value and the partition key index type. If the partition key index type is empty, the index key value is directly the partition key value. Otherwise, obtain the corresponding partition key value in the corresponding partition key index file according to the partition index key type.

[0048] S5. Insert the partition key value into the migration record, calculate the sub-table number using the partition key value, write the sub-table number into the data file to obtain the target table file containing the migration record and the sub-table number. Obtain the corresponding partition key value according to the partition key index type in the first group of configuration parameters, and then calculate the sub-table number to which the current data record belongs from the partition key value according to the partition rule. When converting data, obtain the mapping relationship of the column value in the source data record in the third group of configuration parameters according to the column name of each column in the second group of configuration parameters, obtain the original value of the column from the data record through the mapping relationship and the character set encoding in the second group of configuration parameters, and right-fill spaces with a new value of the specified length according to the data type and length of the column in the second group of configuration parameters. At the same time, obtain the corresponding original value from the data record according to the mapping relationship and the character set encoding of the second group of configuration parameters. If the character set encoding in the third group of configuration parameters is the same as the encoding format in the mapping relationship, no conversion is performed, otherwise the encoding conversion is performed to obtain the original value. After conversion, the formatted data file is converted and split into multiple target table files ending with the sub-table number, and each target table file corresponds to the target sub-table with the same sub-table number.

[0049] S6. Determine the sub-library number to which the target table file belongs according to the sub-table number, and load the target table file into the sub-table with the same sub-table number under the sub-library corresponding to the sub-library number. According to actual needs, the target table file can be loaded into the sub-table with the same sub-table number under the sub-library corresponding to the sub-library number, including loading the target table file into the Oracle database sub-library and sub-table, or the target table file can be loaded into the general relational database sub-library and sub-table.

[0050] Another aspect of the present invention also relates to a sub-library and sub-table migration system supporting heterogeneous data, the structure of which is as follows: Figure 2 As shown, including:

[0051] The data unloading module is used to unload the data to be migrated into one or more data files. For example, for the IBM mainframe platform, it is applicable to z / OS (IBM mainframe operating system), and unloads the VSAM (Virtual Storage Access Method) data set and DB2 database on the IBM mainframe into formatted data files and partition key indexes encoded in the EBCDIC (Extended Binary Coded Decimal Interchange Code) character set. For the open platform, it receives the database identifier and data table name, connects to the original centralized library through the database identifier, queries and obtains the table structure according to the data table name, assembles the paging unloading statement according to the data type and length of each column, where the number of records per page is a configurable parameter, unloads the original data table data into multiple formatted data files, and uses the data table name and page number combination as the data file name, such as the original centralized library table_a table, the unloaded data files are named table_a.P01, table_a.P02, ..., etc. For a data table with a small amount of data less than one page, only the first page of the formatted data file is unloaded. When assembling the unloading statement, fixed-length character data is directly output, variable-length character data is right-filled with spaces for fixed-length output, numeric data is first converted to characters and then left-filled with spaces for fixed-length output, time and date data are converted to fixed-length characters according to the specified format for output, and null values ​​are converted to fixed-length full-space output. At the same time, for the partition key index of the open platform, the database identifier, data table name, partition key index type, index key column name, and partition key column name are received, and the original centralized library is connected through the database identifier. The partition key index unloading statement is assembled according to the data table name, index key column name, and partition key column name, and the partition key index data file is output. The index file format is index key value, partition key index type, and partition key value. The corresponding partition key value can be easily found through the index key value and partition index type.

[0052] The data file reorganization module is used to reorganize each data record in the data file into the migration record of the corresponding target table. The target table name without the sub-table number is received. Through the target table name, three groups of configuration parameters can be obtained. The first group of configuration parameters is the source formatted data file attribute information corresponding to the target table, including the data file name, data record length, index key column name, and partition key index type. The second group of configuration parameters is the sub-table data file format information corresponding to the target table structure, including the character set encoding and the column name, data type, length, and SQL function of each column. The third group of configuration parameters is the column mapping information from the source formatted data file to the target table, including the position, length, and encoding format of the values ​​of each column and index key column of the target table in the data record of the source formatted data file. Then the module determines the source data file for processing according to the data file name in the first group of configuration parameters. If the data file name contains wildcards, the matching data files are processed in sequence.

[0053] The partition table processing module is used to obtain the partition key value and use the partition key value to calculate the partition table number to obtain the target table file. The source data file is read, each data record is parsed according to the record length in the first set of configuration parameters, and the mapping relationship between the index key column value in the source data record is obtained in the third set of configuration parameters according to the index key column name in each set of configuration parameters. The original value of the index key value is obtained from the data record through the mapping relationship and the character set encoding in the second set of configuration parameters, and then the corresponding partition key value is obtained according to the partition key index type in the first set of configuration parameters. Then, the partition table number to which the current data record belongs is calculated from the partition key value according to the partition rule. Then, the module obtains the mapping relationship between the column value in the source data record in the third set of configuration parameters according to the column name of each column in the second set of configuration parameters, obtains the original value of the column from the data record through the mapping relationship and the character set encoding in the second set of configuration parameters, and right-fills with spaces to a new value of the specified length according to the data type and length of the column in the second set of configuration parameters. The corresponding original value is obtained from the data record according to the mapping relationship and the character set encoding of the second set of configuration parameters. If the character set encoding in the third set of configuration parameters is the same as the encoding format in the mapping relationship, no conversion is performed, otherwise the encoding conversion is performed to obtain the original value. The partition key value is obtained according to the original value of the index key and the partition key index type. If the partition key index type is empty, the index key value is directly the partition key value, otherwise the corresponding partition key value is obtained in the corresponding partition key index file according to the partition index key type. After the module parses the data record, according to the column order in the second set of configuration parameters, the new values ​​of each column of the target table are combined into a new sub-table data record, and written into the sub-table data file with the corresponding sub-table number. Finally, all data records are parsed, and all sub-table data files with sub-table numbers are output.

[0054] A data loading module is used to load the target table file into the corresponding sub-library and sub-table. According to different usage requirements, an Oracle Sqlldr data loading module can be used to load the sub-table data file into the target Oracle database sub-library and sub-table through the Oracle sqlldr data loading tool. The module receives the target table name without the sub-table number, obtains the second group of configuration parameters of the aforementioned data file conversion and splitting module through the target table name, parses the column name, data type, length, and SQL function of each column, and determines the corresponding sub-table data file and Oracle database sub-library of each sub-table according to the mapping relationship from all sub-table numbers to sub-library numbers, generates sqlldr data loading commands and corresponding sqlldr control files for all sub-tables, wherein the SQL function in the second group of configuration parameters is combined in the corresponding column options of the sqlldr control file, and further SQL conversion is performed on the corresponding column values ​​of the sub-table data file to be loaded. If the SQL function is not configured, no conversion is performed, and finally the generated sqlldr commands of each sub-table are executed to complete the loading of the Oracle database sub-table. A general relational database data loading module can also be used to load sub-library and sub-table data files into sub-library and sub-tables of a general relational database. The module receives a target table name without a sub-table number, obtains the second set of configuration parameters of the aforementioned data file conversion and splitting module through the target table name, parses the column name, data type, length, and SQL function of each column, converts all sub-table data files into sub-table SQL files with sub-table numbers containing general SQLInsert statements, wherein the SQL function combination in the second set of configuration parameters is further SQL converted in the corresponding column value of the Value clause of the SQLInsert statement, and finally, according to the mapping relationship between all sub-table numbers and sub-library numbers, the sub-library of the relational database is connected, each sub-table SQL file is executed, and the loading of the sub-table of the general relational database is completed.

[0055] By using this system, the above-mentioned operation processing method can be executed and the corresponding technical effects can be achieved.

[0056] An embodiment of the present invention also provides a computer-readable storage medium capable of implementing all the steps in the method in the above embodiment, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, all the steps in the method in the above embodiment are implemented.

[0057] An embodiment of the present invention also provides an electronic device for executing the above method. As an implementation device of the method, the electronic device at least has a processor and a memory, and in particular, the memory stores data and related computer programs required for executing the method, such as data to be migrated and table parameters, etc., and the processor calls the data and program in the memory to execute all steps of the implementation method and obtains the corresponding technical effect.

[0058] Preferably, the electronic device may include a bus architecture, the bus may include any number of interconnected buses and bridges, and the bus will include various circuits linked together by one or more processors and memories. The bus may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are all well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the receiver and transmitter. The receiver and transmitter may be the same component, i.e., a transceiver, providing a unit for communicating with various other systems over a transmission medium. The processor is responsible for managing the bus and general processing, while the memory may be used to store data used by the processor when performing operations.

[0059] In addition, the electronic device may further include components such as a communication module, an input unit, an audio processor, a display, and a power supply. The processor (or controller, operation control) used may include a microprocessor or other processor device and / or a logic device, which receives input and controls the operation of various components of the electronic device; the memory may be one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory, or other suitable devices, which may store the above-mentioned related data information, and may also store a program for executing related information, and the processor may execute the program stored in the memory to realize information storage or processing, etc.; the input unit is used to provide input to the processor, for example, it may be a key or a touch input device; the power supply is used to provide power to the electronic device; the display is used to display display objects such as images and text, for example, it may be an LCD display. The communication module is a transmitter / receiver that sends and receives signals via an antenna. The communication module (transmitter / receiver) is coupled to the processor to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal. Based on different communication technologies, multiple communication modules may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless local area network module, etc. The communication module (transmitter / receiver) is also coupled to a speaker and a microphone via an audio processor to provide an audio output via the speaker and receive an audio input from the microphone, thereby realizing a common telecommunication function. The audio processor may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor is also coupled to a central processor, so that recording can be performed on the machine through the microphone, and the sound stored on the machine can be played through the speaker.

[0060] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0061] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A system that specifies the functions of a box or multiple boxes.

[0062] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction system, which is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0063] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a box or multiple boxes. Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they know the basic creative concept. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0064] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for migrating sharded databases and tables supporting heterogeneous data, characterized in that: include: S1. Unloading the data to be migrated into one or more data files, wherein the data files contain a number of formatted data records, and the formatted data records have the same data record length and data column length; The S1 further comprises: Verify that the data file contains the partition key column; When the data file includes a partition key column, a partition key index is created using the partition key column, wherein the partition key index includes a partition key value; When the data file does not contain a partition key column, determine the external partition key column corresponding to the primary key of the data file based on the foreign key reference relationship between the tables of the data to be migrated, and use the external partition key column to create a partition key index; S2. Obtain table parameters corresponding to the target table, wherein the table parameters include data file attribute information corresponding to the target table, target table format information, and data file corresponding to the target table mapping information, wherein the data file attribute information includes the name of the data to be migrated, the data record length, the partition key index column name, and the partition key index type; the target table format information includes the character set encoding, the column name of each column of the target table, the target table data type, the target table record length, and the SQL function; the data file corresponding to the target table mapping information includes the position, length, and encoding format of each column and index key value of the target table in the data to be migrated; S3. Reorganize each data record in the data file into a migration record corresponding to the target table according to the table parameters, including: S31, determining the data file to be processed according to the name of the data file to be migrated in the data file attribute information; S32, parsing the data file according to the data record length, and obtaining the corresponding index key value mapping relationship according to the partition key index column name matching; S33, obtaining the index key value from the formatted data record of the data file using the character set encoding according to the index key value mapping relationship; S4. Obtain the corresponding partition key value according to the index key value and partition key index type of the migration record; S5. Insert the partition key value into the migration record, use the partition key value to calculate the sub-table number, write the sub-table number into the data file to obtain a target table file containing the migration record and the sub-table number; The method of calculating the sub-table number using the partition key value includes: Check whether the partition key value corresponds to the partition key index type; When the partition key value corresponds to the partition key index type, the partition key value is used to calculate the shard table number according to the preset partition rule; When the partition key value does not correspond to the partition key index type, the corresponding partition key value is retrieved according to the partition key index type, and the corresponding partition key value is used to calculate the shard table number according to the preset partition rule; S6. Determine the sub-library number to which the target table file belongs according to the sub-library number, and load the target table file into the sub-table with the same sub-table number under the sub-library corresponding to the sub-library number.

2. The method according to claim 1, characterized in that The S1 further comprises: When the volume of a single data file exceeds the system limit, the data to be migrated is unloaded into multiple data files, and the multiple data files have the same file name structure and file name prefix.

3. The method according to claim 1, characterized in that The step of loading the target table file into a sub-table with the same sub-table number under a sub-library corresponding to the sub-library number includes loading the target table file into an Oracle database sub-library sub-table, and / or loading the target table file into a general relational database sub-library sub-table.

4. A sub-library and sub-table migration system supporting heterogeneous data, characterized in that: The method according to any one of claims 1 to 3 comprises: A data unloading module is used to unload the data to be migrated into one or more data files; The data unloading module is also used for: Verify that the data file contains the partition key column; When the data file includes a partition key column, a partition key index is created using the partition key column, wherein the partition key index includes a partition key value; When the data file does not contain a partition key column, determine the external partition key column corresponding to the primary key of the data file based on the foreign key reference relationship between the tables of the data to be migrated, and use the external partition key column to create a partition key index; The data file reorganization module is used to reorganize each data record in the data file into the migration record of the corresponding target table, including: Determine the data file to be processed according to the name of the data file to be migrated in the data file attribute information; Parse the data file according to the data record length, and obtain the corresponding index key value mapping relationship according to the partition key index column name matching; Obtain the index key value from the formatted data record of the data file using the character set encoding according to the index key value mapping relationship; The partition table processing module is used to obtain the partition key value and use the partition key value to calculate the partition table number to obtain the target table file; The method of calculating the sub-table number using the partition key value includes: Check whether the partition key value corresponds to the partition key index type; When the partition key value corresponds to the partition key index type, the partition key value is used to calculate the shard table number according to the preset partition rule; When the partition key value does not correspond to the partition key index type, the corresponding partition key value is retrieved according to the partition key index type, and the corresponding partition key value is used to calculate the shard table number according to the preset partition rule; The data loading module is used to load the target table file into the corresponding sub-library and sub-table.

5. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.

6. An electronic device, characterized in that: including a processor and a memory; The memory is used to store the data to be migrated and table parameters; The processor is used to execute the method according to any one of claims 1 to 3 by calling the data to be migrated and the table parameters.