Data migration method and device based on different users and electronic equipment
By creating technical tables and system tables in the database, automatically generating and executing data migration statements, and adopting parallel migration strategies and emergency plans, we solve the problems of long data migration and low efficiency in the existing technology, and achieve fast and complete data migration. Migration to reduce impact on business.
Patent Information
- Application Number
- CN202410780113.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-08-30
AI Technical Summary
The data migration method in the existing technology takes a long time and the migration efficiency is low. It is difficult to quickly complete the migration of large amounts of data, which affects the normal operation of the business.
By creating technical tables and system tables in the database, automatically generating data migration statements, executing the first data migration statement and the second data migration statement, migrating data from the first user to the second user, using parallel migration strategies and emergency plans, Optimize the data table structure to improve migration efficiency.
It realizes the rapid and complete migration of database data to new users, reduces the impact on business, improves migration efficiency, and solves the problem of low migration efficiency in data pump export mode.
Smart Images

Figure CN118568075A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data, financial technology or other related technical fields, and specifically to a method and device for data migration between different users, and an electronic device. Background Art
[0002] In the information society, fully and effectively managing and utilizing various information resources is a prerequisite for scientific research and decision-making management. Database technology is the core part of various information systems such as management information systems, office automation systems, and decision support systems, and is an important technical means for scientific research and decision-making management.
[0003] The database is a warehouse that organizes, stores and manages data according to the data structure. With the development of information technology and the development of business, the amount of data continues to increase, and the old data system is difficult to meet the data management needs. At this time, the original database architecture can be optimized by splitting the database. Generally speaking, it is very difficult to split the database directly. It is difficult to migrate the massive data and functional points from the main application while ensuring the normal operation of the business. Therefore, logical decoupling becomes the preparation for database splitting. The logical decoupling of the database usually divides the original main user into multiple sub-users, and completely migrates the database objects of the main user to the sub-users, so as to achieve the decoupling of business logic at the user level, and then it will be relatively simple to physically split the database.
[0004] In the related art, when migrating data in a database, the copy migration method is mostly used. The full amount of database data can be exported based on a data pump, and then the data pump is used to import it after the new user establishes a new data structure. The above data migration method exported by the data pump is time-consuming and results in low migration efficiency. For migration scenarios with large amounts of data, it is difficult to migrate data quickly, resulting in long-term stagnation of business and affecting the normal operation of the business.
[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiments of the present invention provide a method and device for data migration between different users, and an electronic device, so as to at least solve the technical problem in the related art that data migration is performed by exporting through a data pump, which is time-consuming and has low migration efficiency.
[0007] According to one aspect of an embodiment of the present invention, a method for data migration between different users is provided, including: determining a data table set to be migrated by a first user, and creating a technical table and a second user for receiving the data table set based on the data table set, wherein the data table set includes N data tables, and the technical table is used to record the migration information of the first user, and the first user and the second user are different users in the same database; generating a first data migration statement based on data field information in the technical table; querying a system table in the data table set, and generating a second data migration statement based on data structure field information in the system table, wherein the system table is used to record the structure information of the database to which the first user belongs; executing the first data migration statement and the second data migration statement to migrate the data table set from the first user to the second user.
[0008] Optionally, the step of creating a second user for receiving the data table set based on the data table set includes: creating a table space and a partition space based on the data table set, wherein the table space and the partition space are both logical units for storing data in the database, and the spatial range of the table space is larger than the spatial range of the partition space; creating a second user based on the table space and the partition space, and configuring permission information for the second user.
[0009] Optionally, the step of configuring permission information for the second user includes: configuring access permission information for the table space and the partition space for the second user; and configuring operation permission information for the data table for the second user.
[0010] Optionally, before executing the first data migration statement and the second data migration statement, it also includes: executing the first data migration statement and the second data migration statement in a test environment, and recording the migration time of each data table; creating a parallel task based on the migration time of the data table, wherein the parallel task is used to parallel migrate a set of data tables whose migration time difference is less than a preset difference threshold.
[0011] Optionally, after migrating the data table set from the first user to the second user, it also includes: updating the technical table; obtaining the data table that failed to migrate from the updated technical table; for the data table that failed to migrate, configuring a migration failure emergency plan based on the type of the data table.
[0012] Optionally, after migrating the data table set from the first user to the second user, it also includes: performing table analysis in batches on the data table set migrated to the second user to obtain analysis results, wherein the analysis content of the table analysis includes at least one of the following: analyzing the index validity of the data table, analyzing the data query efficiency, and analyzing the integrity of the data table; and optimizing the data table of the second user based on the analysis results.
[0013] Optionally, before executing the first data migration statement and the second data migration statement, the method further includes: recording the data volume of the data table set to be migrated; and modifying identification information of each data table in the data table set to be migrated of the first user.
[0014] According to another aspect of an embodiment of the present invention, there is also provided a data migration device based on different users, including: a creation unit, used to determine a data table set to be migrated by a first user, and to create a technical table based on the data table set and a second user for receiving the data table set, wherein the data table set includes N data tables, and the technical table is used to record the migration information of the first user, and the first user and the second user are different users in the same database; a first generation unit, used to generate a first data migration statement based on the data field information in the technical table; a second generation unit, used to query a system table in the data table set, and to generate a second data migration statement based on the data structure field information in the system table, wherein the system table is used to record the structure information of the database to which the first user belongs; a migration unit, used to execute the first data migration statement and the second data migration statement to migrate the data table set from the first user to the second user.
[0015] Optionally, the creation unit includes: a first creation module, used to create a table space and a partition space based on the data table set, wherein the table space and the partition space are logical units for storing data in the database, and the spatial range of the table space is larger than the spatial range of the partition space; a first configuration module, used to create a second user based on the table space and the partition space, and configure permission information for the second user.
[0016] Optionally, the first configuration module includes: a first configuration submodule, used to configure access permission information for the table space and the partition space for the second user; and a second configuration submodule, used to configure operation permission information for the data table for the second user.
[0017] Optionally, the data migration device based on different users also includes: a first execution module, used to execute the first data migration statement and the second data migration statement in a test environment, and record the migration time of each data table; a second creation module, used to create parallel tasks based on the migration time of the data table, wherein the parallel tasks are used to perform parallel migration on a set of data tables whose migration time difference is less than a preset difference threshold.
[0018] Optionally, the data migration device based on different users also includes: a first update module, used to update the technical table; a first acquisition module, used to obtain the data table that failed to migrate from the updated technical table; and a second configuration module, used to configure a migration failure emergency plan for the data table that failed to migrate based on the type of the data table.
[0019] Optionally, the data migration device between different users also includes: a first analysis module, used to perform table analysis on the set of data tables migrated to the second user in batches to obtain analysis results, wherein the analysis content of the table analysis includes at least one of the following: analyzing the index validity of the data table, analyzing the data query efficiency, and analyzing the integrity of the data table; a first optimization module, used to optimize the data table of the second user based on the analysis results.
[0020] Optionally, the data migration device based on different users further includes: a first recording module, used to record the data volume of the data table set to be migrated; and a first modification module, used to modify the identification information of each data table in the data table set to be migrated of the first user.
[0021] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above-mentioned data migration methods between different users.
[0022] According to another aspect of an embodiment of the present invention, a computer program product is further provided. The computer program product includes a computer program, wherein when the computer program is executed by a processor, any one of the above-mentioned data migration methods between different users is implemented.
[0023] In the present disclosure, the following steps are performed: first determine a data table set to be migrated by a first user, and create a technical table and a second user for receiving the data table set based on the data table set, wherein the data table set includes N data tables, and the technical table is used to record the migration information of the first user, and the first user and the second user are different users in the same database, and then generate a first data migration statement based on the data field information in the technical table, and then query the system table in the data table set, and generate a second data migration statement based on the data structure field information in the system table, wherein the system table is used to record the structure information of the database to which the first user belongs, and finally execute the first data migration statement and the second data migration statement to migrate the data table set from the first user to the second user.
[0024] In the present disclosure, data migration statements can be automatically generated through pre-constructed technical tables and field information recorded in system tables generated by a database server. By executing the first data migration statement and the second data migration statement in sequence, the data managed by the first user in the database can be quickly and completely migrated to the new user, thereby improving migration efficiency and reducing the impact on business processing, thereby solving the technical problem of data migration through data pump export in related technologies, which is time-consuming and has low migration efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0026] Figure 1 is a flow chart of an optional method for data migration between different users according to an embodiment of the present invention;
[0027] Figure 2 is a schematic diagram of an optional data migration process between different users according to an embodiment of the present invention;
[0028] Figure 3 is a schematic diagram of an optional data migration device between different users according to an embodiment of the present invention;
[0029] Figure 4 The present invention is a hardware structure block diagram of an electronic device (or mobile device) based on a data migration method between different users according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] To facilitate those skilled in the art to understand the present invention, some terms or nouns involved in the embodiments of the present invention are explained below:
[0033] CTAS statement, an SQL statement used to copy data, is the abbreviation of Create Table As Select and is used to migrate data to a new data object based on an existing data source (such as a table or query results).
[0034] It should be noted that the data migration method and device based on data migration between different users in the present disclosure can be used in the big data field when migrating data tables between different users, and can also be used in any field except the big data field when migrating data tables between different users. The present disclosure does not limit the application field of the data migration method and device based on data migration between different users.
[0035] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0036] It should be noted that in the present disclosure, when collecting and analyzing customer information, corresponding operation entrances are provided for users to choose to agree or reject the automated decision results; if the user chooses to reject, the expert decision process is entered.
[0037] The following embodiments of the present invention can be applied to various data migration systems / applications / devices based on different users. The present invention automatically generates data migration statements based on pre-built technical tables and system tables generated by database servers, reducing the work cost of manually writing scripts. Based on the first data migration statement and the second data migration statement, the data table to be migrated by the first user in the database can be quickly and completely migrated to the newly created second user, solving the problem of long time consumption and low efficiency when exporting data based on data pump.
[0038] The present invention is divided into a preparation phase, a migration phase and a verification phase when performing data migration. The preparation phase and the verification phase do not affect business processing, and the impact on business processing can be minimized. At the same time, in the migration phase, operations on the migration data table are rigidly stopped to ensure data consistency and avoid data loss.
[0039] The data migration method of the present invention has strong scalability, can customize the emergency plan for migration failure based on the data table type, and can customize the compensation method according to the business scenario.
[0040] The present invention is described in detail below in conjunction with various embodiments.
[0041] Embodiment 1
[0042] According to an embodiment of the present invention, an embodiment of a data migration method between different users is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0043] Figure 1 is a flow chart of an optional method for data migration between different users according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0044] Step S101, determining a data table set to be migrated by a first user, and creating a technical table and a second user for receiving the data table set based on the data table set, wherein the data table set includes N data tables, the technical table is used to record migration information of the first user, and the first user and the second user are different users in the same database;
[0045] Step S102, generating a first data migration statement according to the data field information in the technical table;
[0046] Step S103, querying a system table in the data table set, and generating a second data migration statement based on data structure field information in the system table, wherein the system table is used to record structure information of a database to which the first user belongs;
[0047] Step S104 , executing the first data migration statement and the second data migration statement to migrate the data table set from the first user to the second user.
[0048] Through the above steps, the data table set to be migrated by the first user is first determined, and a technical table and a second user for receiving the data table set are created based on the data table set, wherein the data table set includes N data tables, and the technical table is used to record the migration information of the first user, and the first user and the second user are different users in the same database. Then, a first data migration statement is generated according to the data field information in the technical table, and then a system table is queried in the data table set, and a second data migration statement is generated based on the data structure field information in the system table, wherein the system table is used to record the structure information of the database to which the first user belongs. Finally, the first data migration statement and the second data migration statement are executed to migrate the data table set from the first user to the second user.
[0049] In this embodiment, data migration statements can be automatically generated through the pre-constructed technical table and the field information recorded in the system table generated by the database server. The first data migration statement and the second data migration statement are executed in sequence, so that the data managed by the first user in the database can be quickly and completely migrated to the new user, thereby improving migration efficiency and reducing the impact on business processing, thereby solving the technical problem of data migration through data pump export in related technologies, which is time-consuming and has low migration efficiency.
[0050] The embodiment of the present invention is described in detail below in combination with the above steps.
[0051] At present, with the popularization of informatization, data has become one of the most important assets, so data management is also crucial. Data management not only needs to meet the needs of data capacity, but also needs to meet the needs of technological development. Data migration is an important part of data management. With the development of technology, enterprises may need to upgrade to more advanced systems to improve efficiency and performance. Data splitting can be used as a system upgrade strategy to optimize the database.
[0052] It should be noted that the data in the database can be stored in units of users, and users have full access and control rights to the data under their own accounts. When upgrading the system, it is very difficult to directly split the database. It is difficult to migrate massive data and functional points from the main application while ensuring normal business operations. Therefore, logical decoupling becomes the preparatory work for database splitting. The logical decoupling of the database usually involves dividing the original main user into multiple sub-users and completely migrating the database objects of the main user to the sub-users, thereby achieving the decoupling of business logic at the user level, and then the physical splitting of the database will be relatively simple.
[0053] It should be noted that the data migration scheme of the embodiment of the present invention is divided into three stages, namely, the preparation stage, the migration stage and the verification stage. The preparation stage and the verification stage do not affect the normal operation of the business, while the migration stage will affect the normal operation of the business, thereby ensuring the normal execution of the business to the greatest extent and reducing the impact on business handling. In the preparation stage, it is necessary to create a technical table, create a second user, and construct a first data migration statement and a second data migration statement; in the migration stage, the first data migration statement and the second data migration statement are executed to migrate the data from the data structure of the original user to the data structure of the new user; in the verification stage, it is checked whether the data has been completely migrated, thereby ensuring the integrity and accuracy of the migrated data.
[0054] Step S101 : determining a data table set to be migrated by a first user, and creating a technical table and a second user for receiving the data table set based on the data table set.
[0055] It should be noted that the above-mentioned first user refers to the user who manages the data tables to be migrated in the database, and the second user is the user who receives the data tables to be migrated in the database. The above-mentioned data table set includes N (N is a positive integer) data tables. The technical table is used to record the migration information of the first user. The first user and the second user are different users belonging to the same database. The first user and the second user can be the main user and the sub-user. The first user can migrate all or part of his own data tables to the second user, thereby realizing logical decoupling at the business level and providing a good environment for database splitting.
[0056] It should be noted that when migrating the entire database, since the amount of data in the database is too large, the users in the database can be migrated in batches. A first user is selected, all data tables managed by the first user are obtained, a set of data tables to be migrated is obtained, and a technical table is constructed based on the set of data tables to be migrated. The technical table is a table for recording the migration information of the first user. An exemplary technical table is shown in Table 1.
[0057] Table 1 Exemplary technical table
[0058]
[0059]
[0060] As shown in Table 1, the technical table records migration information such as number, data object name, type, old user (i.e., the first user), second user, new table space, new index space, copy data logic, execution statement, data volume before migration, data volume after migration, job group, success or failure information, start time, completion time, and custom fields. The example values corresponding to the fields in the technical table will be updated in real time as the data is migrated. The latest data migration information can be obtained by querying the technical table.
[0061] Optionally, the step of creating a second user for receiving the data table set based on the data table set includes: creating a table space and a partition space based on the data table set, wherein the table space and the partition space are both logical units for storing data in the database, and the spatial range of the table space is larger than the spatial range of the partition space; creating a second user based on the table space and the partition space, and configuring permission information for the second user.
[0062] It should be noted that in the data preparation stage, in addition to creating technical tables, you also need to create a second user. The second user can be a sub-user created for the first user. The second user and the first user belong to the same database. Divide the new database, create table spaces and partition spaces. Table spaces and partition spaces are both logical units for storing data in the database. Partition spaces are finer-grained divisions than table spaces. A table space can contain multiple partition spaces. Then create a second user based on the divided table spaces and partition spaces, and configure permission information for the second user.
[0063] Optionally, the step of configuring permission information for the second user includes: configuring access permission information for the table space and the partition space for the second user; and configuring operation permission information for the data table for the second user.
[0064] It should be noted that the permission information configured for the second user may include: access permissions to the newly created table space and partition space, and access permissions and operation permissions to the data table to be migrated.
[0065] Step S102: Generate a first data migration statement according to the data field information in the technical table.
[0066] It should be noted that the embodiment of the present invention can automatically generate the first data migration statement based on the pre-built technical table. Specifically, according to the data field information in the technical table, such as the data object name, type, second user, old user, copy data logic and other field information, the CTAS statement (i.e., the first data migration statement) to be executed is dynamically spliced. This statement can only migrate the fields in the data table, and cannot copy the primary key, index, table space and other structural information. The basic syntax of the CTAS statement is as follows:
[0067] CREATE TABLE new_tab le ASSELECT*FROM exi st ing_tab leWHERE condition;
[0068] Here new_table is the name of the new table being created, exiting_table is the existing table that serves as the data source, and condition is an optional filter that can be used to select rows of data to be included in the new table, thereby migrating data from the existing table to the new table.
[0069] Step S103: query the system table in the data table set, and generate a second data migration statement based on the data structure field information in the system table.
[0070] It should be noted that the above-mentioned system table is used to record the structural information of the database to which the first user belongs. Since the first data migration statement can only migrate the field information in the data table, and the storage structure information of the data table cannot be realized by the first data migration statement, it is also necessary to construct a supplementary statement (i.e., the second data migration statement) to ensure the integrity of the migrated data.
[0071] It should be noted that the system table is a table generated by the database server and contains database structure information. By querying the system table, structural information such as the primary key information, index information, table partition information, and comment information of the data table to be migrated can be extracted from the system table, thereby dynamically splicing the second data migration statement to be executed.
[0072] Optionally, before executing the first data migration statement and the second data migration statement, it also includes: executing the first data migration statement and the second data migration statement in a test environment, and recording the migration time of each data table; creating a parallel task based on the migration time of the data table, wherein the parallel task is used to perform parallel migration on a set of data tables whose migration time difference is less than a preset difference threshold.
[0073] It should be noted that the embodiments of the present invention can execute data migration in parallel by configuring different job groups, executing sequentially within the group and concurrently between groups, so as to quickly perform data migration. In order to maximize the efficiency of concurrent execution, data migration tasks with smaller migration times are usually selected for concurrent execution, that is, the execution times of migration tasks executed concurrently at the same time are almost the same, avoiding the problem of resource waste due to the short execution time of a certain migration task, thereby maximizing the system execution efficiency.
[0074] It should be noted that in order to achieve parallel migration, it is first necessary to execute the first data migration statement and the second data migration statement in the test environment, calculate the time taken by each first user to perform data migration, obtain the migration duration, select multiple data table sets with similar migration duration, create parallel tasks, execute data migration in parallel, and improve migration efficiency.
[0075] Optionally, before executing the first data migration statement and the second data migration statement, the method further includes: recording the data volume of the data table set to be migrated; and modifying identification information of each data table in the data table set to be migrated of the first user.
[0076] It should be noted that before executing the first data migration statement and the second migration statement, in order to ensure that the data in the data table to be migrated will not be tampered with during the data migration process, resulting in inconsistent data before and after migration, it is also necessary to modify the identification information of the data table to be migrated, and the identification information needs to be rolled back to the original identification information if the migration of the data table fails, to ensure the normal handling of subsequent business in the event of a migration failure.
[0077] In another optional embodiment, before executing the first data migration statement and the second migration statement, it is also necessary to count and record the data volume of the data table set to be migrated for comparison with the data volume of the successfully migrated data table set to determine whether there is data loss before and after the migration.
[0078] Step S104 , executing the first data migration statement and the second data migration statement to migrate the data table set from the first user to the second user.
[0079] It should be noted that, during the data migration phase, the first data migration statement and the second data migration statement are automatically executed to copy the fields and data structures in the data table set to be migrated to the second user to achieve data migration.
[0080] Optionally, after migrating the data table set from the first user to the second user, it also includes: performing batch table analysis on the data table set migrated to the second user to obtain analysis results, wherein the analysis content of the table analysis includes at least one of the following: analyzing the index validity of the data table, analyzing the data query efficiency, and analyzing the integrity of the data table; and optimizing the data table of the second user based on the analysis results.
[0081] It should be noted that during the data migration phase, it is also necessary to perform table analysis on the data table of the second user after the data is migrated to the second user. As an important database maintenance process, table analysis can help database administrators understand the current status of the data table and optimize database performance. For example, the query efficiency of the migrated data table can be obtained through table analysis. If the query efficiency is low, the query efficiency of the data table can be improved, and slow queries can be checked and query plans can be analyzed to determine the bottleneck. At the same time, table analysis can also be used to obtain the validity of the data table index, whether there are too many indexes or missing indexes, etc. The integrity of the data table can also be obtained through table analysis to ensure that the data meets all defined integrity constraints, such as primary keys, foreign keys, uniqueness constraints, etc. The analysis results of the table analysis operation can be used to optimize the data table of the second user.
[0082] Optionally, after migrating the data table set from the first user to the second user, the method further includes: updating the technical table; obtaining the data table that failed to migrate from the updated technical table; and configuring a migration failure emergency plan for the data table that failed to migrate based on the type of the data table.
[0083] It should be noted that after migrating the data table to the second user, it is also necessary to verify the migrated data table, receive the system's error notification, obtain the data table that failed to migrate based on the error notification, and for the data table that failed to migrate, obtain the type of the data table. Configure different migration failure emergency plans for different types of data tables. For example, non-important business data tables or data tables that have been stored for a long time can be discarded directly. For some important business data tables, data can be rolled back by creating synonyms, so that the application can access the original user's data table through a familiar name. You can also roll back the data table that failed to migrate by creating a rollback script.
[0084] In addition, after the data table is migrated to the second user, the technical table is updated based on the migration status of the data table, so that the technical table records the latest migration information of the data table.
[0085] Another optional specific implementation is described in detail below.
[0086] Figure 2 is a schematic diagram of an optional data migration process between different users according to an embodiment of the present invention, such as Figure 2 As shown, the data migration process can migrate the data of the first user to the table space and partition space where the second user is located. The data migration process is divided into a preparation phase, a migration phase, and a verification phase. The preparation phase and the verification phase do not affect business processing, while the migration phase affects business processing. Specifically,
[0087] Preparation stage:
[0088] Step 1, start;
[0089] Step 2: Create a second user, a new table space and partition space, and authorize the second user;
[0090] Step 3: assign permissions of the data table to be migrated to the second user;
[0091] Step 4: Record the amount of data in the data table to be migrated;
[0092] Step 5: query the technical table and generate the first data migration statement;
[0093] Step 6: query the system table and generate a second data migration statement;
[0094] Step 7: Modify the identification information of the data table to be migrated;
[0095] Migration phase:
[0096] Step 8, record the execution start time;
[0097] Step nine, executing the first data migration statement;
[0098] Step 10, executing the second data migration statement;
[0099] Step 11, performing table analysis on the migrated second user;
[0100] Step 12, record the execution end time;
[0101] Step 13, record the amount of data in the new table;
[0102] Verification phase:
[0103] Step 14: modify the identifier of the migrated data table to the identifier information of the data table before migration, so that the data table can support business processing again;
[0104] Step 15, reclaiming the redundant permissions of the second user;
[0105] Step 16: Verify whether the migration is successful. If yes, proceed to step 18; if no, proceed to step 17.
[0106] Verifying whether the migration is successful may include: comparing the data volume of the data table to be migrated recorded in the preparation phase with the data volume of the new table recorded in the migration phase. If the data volumes of the two are the same, it indicates that there is no lost data in the data migration. Otherwise, there is lost data and it is necessary to determine the lost data and migrate again.
[0107] In addition, verifying whether the migration is successful may also include: determining whether there is a record of migration failure based on an error notification of the system.
[0108] Step 17: Configure an emergency plan for migration failure.
[0109] Step 18, end.
[0110] In an embodiment of the present invention, data migration statements are automatically generated based on pre-built technical tables and system tables generated by a database server, reducing the labor cost of manually writing scripts. Based on the first data migration statement and the second data migration statement, the data table to be migrated by the first user can be quickly and completely migrated to the second user, solving the problem of long time consumption and low efficiency when exporting data based on a data pump.
[0111] The following is a detailed description in conjunction with another embodiment.
[0112] Embodiment 2
[0113] A data migration device between different users provided in this embodiment includes multiple implementation units, each implementation unit corresponds to each implementation step in the above-mentioned embodiment 1. Its specific implementation method and beneficial effects can refer to the above-mentioned method embodiment and will not be repeated here.
[0114] Figure 3 is a schematic diagram of an optional data migration device between different users according to an embodiment of the present invention, such as Figure 2 As shown, the data migration device based on different users may include: a creation unit 31, a first generation unit 32, a second generation unit 33, and a migration unit 34, wherein:
[0115] A creation unit 31 is used to determine a data table set to be migrated by a first user, and create a technical table and a second user for receiving the data table set based on the data table set, wherein the data table set includes N data tables, the technical table is used to record the migration information of the first user, and the first user and the second user are different users in the same database;
[0116] A first generating unit 32, configured to generate a first data migration statement according to data field information in the technical table;
[0117] The second generating unit 33 is used to query the system table in the data table set, and generate a second data migration statement based on the data structure field information in the system table, wherein the system table is used to record the structure information of the database to which the first user belongs;
[0118] The migration unit 34 is configured to execute a first data migration statement and a second data migration statement to migrate a data table set from the first user to the second user.
[0119] The above-mentioned data migration device based on different users determines the data table set to be migrated by the first user through the creation unit 31, and creates a technical table and a second user for receiving the data table set based on the data table set, wherein the data table set includes N data tables, and the technical table is used to record the migration information of the first user, and the first user and the second user are different users in the same database; generates a first data migration statement according to the data field information in the technical table through the first generation unit 32; queries the system table in the data table set through the second generation unit 33, and generates a second data migration statement based on the data structure field information in the system table, wherein the system table is used to record the structure information of the database to which the first user belongs; executes the first data migration statement and the second data migration statement through the migration unit 34 to migrate the data table set from the first user to the second user.
[0120] In this embodiment, data migration statements can be automatically generated through the pre-constructed technical table and the field information recorded in the system table generated by the database server. The first data migration statement and the second data migration statement are executed in sequence, so that the data managed by the first user in the database can be quickly and completely migrated to the new user, thereby improving migration efficiency and reducing the impact on business processing, thereby solving the technical problem of data migration through data pump export in related technologies, which is time-consuming and has low migration efficiency.
[0121] Optionally, the creation unit 31 includes: a first creation module, used to create a table space and a partition space based on a data table set, wherein the table space and the partition space are both logical units in the database for storing data, and the spatial range of the table space is larger than the spatial range of the partition space; a first configuration module, used to create a second user based on the table space and the partition space, and configure permission information for the second user.
[0122] Optionally, the first configuration module includes: a first configuration submodule, used to configure access permission information for the table space and partition space for the second user; and a second configuration submodule, used to configure operation permission information of the data table for the second user.
[0123] Optionally, the data migration device based on different users also includes: a first execution module, used to execute the first data migration statement and the second data migration statement in a test environment, and record the migration time of each data table; a second creation module, used to create parallel tasks based on the migration time of the data table, wherein the parallel tasks are used to perform parallel migration on a set of data tables whose migration time difference is less than a preset difference threshold.
[0124] Optionally, the data migration device between different users also includes: a first update module, used to update the technical table; a first acquisition module, used to obtain the data table that failed to migrate from the updated technical table; and a second configuration module, used to configure a migration failure emergency plan for the data table that failed to migrate based on the type of the data table.
[0125] Optionally, the data migration device between different users also includes: a first analysis module, used to perform table analysis on a set of data tables migrated to the second user in batches to obtain analysis results, wherein the analysis content of the table analysis includes at least one of the following: analyzing the index validity of the data table, analyzing the data query efficiency, and analyzing the integrity of the data table; a first optimization module, used to optimize the data table of the second user based on the analysis results.
[0126] Optionally, the data migration device based on different users further includes: a first recording module, used to record the data volume of the data table set to be migrated; and a first modification module, used to modify the identification information of each data table in the data table set to be migrated of the first user.
[0127] The above-mentioned data migration device between different users may also include a processor and a memory. The above-mentioned creation unit 31, the first generation unit 32, the second generation unit 33, the migration unit 34, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.
[0128] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels may be provided, and data may be migrated by adjusting kernel parameters.
[0129] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (fl ash RAM), and the memory includes at least one storage chip.
[0130] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned data migration method based on different users.
[0131] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the above-mentioned data migration method based on different users.
[0132] According to another aspect of an embodiment of the present invention, a computer program product is further provided. The computer program product includes a computer program, wherein when the computer program is executed by a processor, any one of the above-mentioned data migration methods between different users is implemented.
[0133] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: determining a data table set to be migrated by a first user, and creating a technical table and a second user for receiving the data table set based on the data table set, wherein the data table set includes N data tables, and the technical table is used to record the migration information of the first user, and the first user and the second user are different users in the same database; generating a first data migration statement based on the data field information in the technical table; querying a system table in the data table set, and generating a second data migration statement based on the data structure field information in the system table, wherein the system table is used to record the structure information of the database to which the first user belongs; executing the first data migration statement and the second data migration statement to migrate the data table set from the first user to the second user.
[0134] The present application also provides a computer program product, which, when executed on a data processing device, is also suitable for executing a program that initializes the following method steps: the step of creating a second user for receiving the data table set based on the data table set, including: creating a table space and a partition space based on the data table set, wherein the table space and the partition space are both logical units for storing data in the database, and the space range of the table space is larger than the space range of the partition space; creating a second user based on the table space and the partition space, and configuring permission information for the second user.
[0135] The present application also provides a computer program product, which, when executed on a data processing device, is also suitable for executing a program that initializes the following method steps: the step of configuring permission information for the second user includes: configuring access permission information for the table space and partition space for the second user; configuring operation permission information of the data table for the second user.
[0136] The present application also provides a computer program product, which, when executed on a data processing device, is also suitable for executing a program that initializes the following method steps: before executing a first data migration statement and a second data migration statement, it also includes: executing the first data migration statement and the second data migration statement in a test environment, and recording the migration duration of each data table; creating a parallel task based on the migration duration of the data table, wherein the parallel task is used to perform parallel migration on a set of data tables whose difference in migration duration is less than a preset difference threshold.
[0137] The present application also provides a computer program product, which, when executed on a data processing device, is also suitable for executing a program that initializes the following method steps: after migrating a set of data tables from a first user to a second user, it also includes: updating the technical table; obtaining the data table that failed to migrate from the updated technical table; for the data table that failed to migrate, configuring a migration failure emergency plan based on the type of the data table.
[0138] The present application also provides a computer program product, which, when executed on a data processing device, is also suitable for executing a program that initializes the following method steps: after migrating a data table set from a first user to a second user, it also includes: performing batch table analysis on the data table set migrated to the second user to obtain analysis results, wherein the analysis content of the table analysis includes at least one of the following: analyzing the index validity of the data table, analyzing the data query efficiency, and analyzing the integrity of the data table; and optimizing the data table of the second user based on the analysis results.
[0139] The present application also provides a computer program product, which, when executed on a data processing device, is also suitable for executing a program that initializes the following method steps: recording the amount of data in a set of data tables to be migrated; and modifying the identification information of each data table in the set of data tables to be migrated by the first user.
[0140] Figure 4 1 is a hardware structure block diagram of an electronic device (or mobile device) based on a data migration method between different users according to an embodiment of the present invention. Figure 4 As shown, the electronic device may include one or more ( Figure 4 402a, 402b, ..., 402n are used to illustrate) processor 402 (processor 402 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), memory 404 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 4 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 4 More or fewer components as shown, or with Figure 4 Different configurations shown.
[0141] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0142] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0143] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0144] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0145] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0146] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0147] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A data migration method between different users, characterized in that: include: Determine a data table set to be migrated for a first user, and create a technical table and a second user for receiving the data table set based on the data table set, wherein the data table set includes N data tables, the technical table is used to record migration information of the first user, and the first user and the second user are different users in the same database; Generate a first data migration statement according to the data field information in the technical table; Querying a system table in the data table set, and generating a second data migration statement based on data structure field information in the system table, wherein the system table is used to record structure information of a database to which the first user belongs; The first data migration statement and the second data migration statement are executed to migrate the data table set from the first user to the second user.
2. The method according to claim 1, characterized in that The step of creating a second user for receiving the data table set based on the data table set includes: Creating a table space and a partition space according to the data table set, wherein the table space and the partition space are both logical units for storing data in the database, and the space range of the table space is larger than the space range of the partition space; A second user is created according to the table space and the partition space, and permission information is configured for the second user.
3. The method according to claim 2, characterized in that The step of configuring permission information for the second user includes: configuring access permission information for the table space and the partition space for the second user; The operation permission information of the data table is configured for the second user.
4. The method according to claim 1, characterized in that: Before executing the first data migration statement and the second data migration statement, the method further includes: Execute the first data migration statement and the second data migration statement in the test environment, and record the migration time of each data table; A parallel task is created based on the migration duration of the data table, wherein the parallel task is used to perform parallel migration on a set of data tables whose migration duration difference is less than a preset difference threshold.
5. The method according to claim 1, characterized in that After migrating the data table set from the first user to the second user, the method further includes: updating said technical sheet; Obtain the data table that failed to be migrated from the updated technical table; For the data table whose migration fails, a migration failure emergency plan is configured based on the type of the data table.
6. The method according to claim 1, characterized in that After migrating the data table set from the first user to the second user, the method further includes: Performing table analysis on the data table set migrated to the second user in batches to obtain analysis results, wherein the analysis content of the table analysis includes at least one of the following: analyzing the index validity of the data table, analyzing the data query efficiency, and analyzing the integrity of the data table; The data table of the second user is optimized based on the analysis result.
7. The method according to claim 1, characterized in that Before executing the first data migration statement and the second data migration statement, the method further includes: Record the amount of data in the data table set to be migrated; Modify identification information of each data table in the data table set to be migrated by the first user.
8. A data migration device between different users, characterized in that: include: a creating unit, configured to determine a data table set to be migrated by a first user, and to create a technical table based on the data table set and a second user for receiving the data table set, wherein the data table set includes N data tables, the technical table is used to record migration information of the first user, and the first user and the second user are different users in the same database; A first generating unit, configured to generate a first data migration statement according to the data field information in the technical table; A second generating unit is configured to query a system table in the data table set, and generate a second data migration statement based on data structure field information in the system table, wherein the system table is used to record structure information of a database to which the first user belongs; A migration unit is used to execute the first data migration statement and the second data migration statement to migrate the data table set from the first user to the second user.
9. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the data migration method based on different users as described in any one of claims 1 to 7.
10. A computer program product, characterized in that The computer program product comprises a computer program, wherein When the computer program is executed by a processor, the method for data migration between different users described in any one of claims 1 to 7 is implemented.
