Data migration method, data migration system and server
By deleting conflicting reserved words in the target database, the migration failure problem caused by conflicting identifiers and reserved words during data migration is solved, and the migration success rate and efficiency are improved.
Patent Information
- Application Number
- CN202311230760.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-20
- Publication Date
- 2025-03-21
AI Technical Summary
During the data migration process, the migration fails because the identifier of the data to be migrated conflicts with the reserved word of the target database.
By obtaining the reserved word to be deleted and deleting the reserved word in the reserved word set of the target database, a new reserved word set is obtained and the original reserved word set is replaced, thereby avoiding migration failure.
It improves the success rate of data migration, avoids intrusion into the original data, and improves the efficiency of data migration.
Smart Images

Figure CN119669182A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a data migration method, a data migration system and a server. Background Art
[0002] Data migration generally refers to the process of migrating data from one database to another for storage. At present, many application scenarios may involve data migration. For example, when expanding regional business, in order to meet the data protection laws of the relevant regions, such as the General Data Protection Regulation that includes the data security of regional citizens, it is necessary to migrate the relevant data of regional citizens from the database deployed in the first region to the database deployed in the second region for storage.
[0003] During the data migration process, it is often possible that the data migration from the first database to the second database fails because the identifier of the first database to which the data belongs before the migration, such as the data table identifier, is the same as the reserved word of the second database to be migrated. For example, in the first database, the identifier of the data table is analyze, and analyze is a reserved word of the second database. When the user migrates the data in the data table with the identifier analyze to the second database, the migration fails because the second database recognizes analyze as a reserved word. Summary of the invention
[0004] The embodiments of the present application provide a data migration method, a data migration system and a server, the purpose of which is to solve the problem of migration failure caused by the conflict between the identifier of the data to be migrated and the reserved word of the database to be migrated during the data migration process.
[0005] In a first aspect, an embodiment of the present application provides a data migration method, the method comprising:
[0006] Obtain reserved words to be deleted, where the reserved words to be deleted are structured query language SQL entity identifiers of the data to be migrated in the first database; when the first reserved word set of the second database includes the reserved words to be deleted, delete the reserved words to be deleted from the first reserved word set to obtain a second reserved word set; replace the first reserved word set in the second database with the second reserved word set, and migrate the data to be migrated from the first database to the second database after the second reserved word set is replaced. It can be seen that the second reserved word set is the reserved word set after the reserved words to be deleted are deleted, and the second reserved word set does not contain reserved words that cause the migration failure of the data to be migrated. Since the current reserved word set of the second database after replacement is the second reserved word set, that is, the second database after replacement does not contain reserved words that cause the migration failure of the data to be migrated, the migration success rate of the data to be migrated from the first database to the second database can be improved.
[0007] In a possible implementation, a first blacklist set is loaded; the reserved words to be deleted are added to the first blacklist set to obtain a second blacklist set; when the first reserved word set of the second database includes the reserved words to be deleted, the reserved words to be deleted in the second blacklist set are deleted from the first reserved word set. The embodiment of the present application introduces a blacklist set mechanism, and the first reserved word set in the second database only needs to process the blacklist reserved words in the blacklist set, thereby improving data processing efficiency.
[0008] Optionally, the reserved words to be deleted can be added to the first blacklist set through the first interface to obtain the second blacklist set. The first interface is a pre-set reserved word adding interface. It can be seen that the embodiment of the present application can obtain the reserved words to be deleted by direct input, which is easy to use.
[0009] In another optional implementation, when the reserved word to be deleted does not belong to the blacklist reserved word in the first blacklist set, the reserved word to be deleted is added to the first blacklist set to obtain a second blacklist set, and the blacklist reserved word is the original reserved word set in the second database, and does not belong to the reserved word in the first reserved word set. It can be seen that the embodiment of the present application saves the reserved words that have been deleted in the first reserved word set of the second database through the first blacklist set. When the reserved word to be deleted belongs to the blacklist reserved word in the first blacklist set, the deletion operation is no longer performed, and the deletion process is omitted. Optionally, when the reserved word to be deleted belongs to the reserved word in the first blacklist set, a warning that it has been deleted is output through the first interface. The user can intuitively determine the relationship between the SQL entity identifier of the data to be migrated in the first database and the reserved word set in the second database, and then perform subsequent operations based on this relationship. In another optional implementation, when the reserved word to be deleted does not belong to the reserved words in the first blacklist set, and the reserved word to be deleted does not belong to the reserved words in the preset whitelist set, the reserved word to be deleted is added to the first blacklist set to obtain a second blacklist set, and the reserved words in the whitelist set are reserved words related to the operation of the second database. The embodiment of the present application introduces a whitelist protection mechanism to avoid the problem that the user arbitrarily deletes the reserved words in the second database, causing the second database to fail to operate normally, thereby improving the stability of the second database system.
[0010] Optionally, when the reserved word to be deleted belongs to a reserved word in a preset whitelist, a deletion failure warning is output through the first interface, which improves the user experience.
[0011] Optionally, the reserved words in the whitelist set include a first reserved word and a second reserved word. The first reserved word is a reserved word in an intersection obtained by intersecting the reserved word sets of multiple databases with the reserved word set of the second database; and the second reserved word is a reserved word related to the function of the second database.
[0012] In another optional implementation, when the reserved word to be deleted is a reserved word in the second database and does not belong to the blacklist reserved words in the first blacklist set, the reserved word to be deleted is added to the first blacklist set to obtain the second blacklist set.
[0013] In another optional implementation, when the first reserved word set of the second database includes the reserved word to be deleted, it is determined whether the reserved word to be deleted belongs to the reserved words in the preset white list set; when it is determined that the reserved word to be deleted does not belong to the reserved words in the preset white list set, the reserved word to be deleted is deleted from the first reserved word set to obtain the second reserved word set. Optionally, when the reserved word to be deleted is not a reserved word in the second database, a non-reserved word warning is output through the first interface.
[0014] Optionally, in response to a user inputting an SQL entity identifier of the data to be migrated in the first database, the reserved word to be deleted is obtained, or the SQL entity identifier of the data to be migrated in the first database is screened from a pre-stored data migration exception log to obtain the reserved word to be deleted. That is, the reserved word to be deleted in the embodiment of the present application can be obtained by input, or can be automatically obtained from the data migration exception log in other ways.
[0015] Optionally, in response to executing the operation of obtaining deleted reserved words, a deleted list is obtained through the second interface, and the reserved words in the deleted list are reserved words that have been deleted from the current second database.
[0016] Optionally, the first database and the second database are heterogeneous databases.
[0017] In a second aspect, an embodiment of the present application provides a data migration system, the system comprising: a lexical analyzer, a replacer, and a migrator;
[0018] The lexical analyzer is used to obtain the reserved words to be deleted; the reserved words to be deleted are the SQL entity identifiers of the data to be migrated in the first database; the reserved words to be deleted are deleted from the first reserved word set of the second database to obtain the second reserved word set; the replacer is used to replace the first reserved word set in the second database with the second reserved word set; the migrator is used to migrate the data to be migrated from the first database to the second database after replacing the second reserved word set.
[0019] In a third aspect, an embodiment of the present application provides a server, including a memory and a processor;
[0020] The memory is coupled to the processor; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes any method of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A schematic diagram of an application scenario of a data migration method provided in an embodiment of the present application;
[0022] Figure 2 A flow chart of the first data migration method provided in the embodiment of the present application;
[0023] Figure 3 A schematic diagram of a data migration system for obtaining reserved words to be deleted provided in an embodiment of the present application;
[0024] Figure 4 A flow chart of a second data migration method provided in an embodiment of the present application;
[0025] Figure 5 A flowchart of a third data migration method provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of the data migration process provided in an embodiment of the present application;
[0027] Figure 7 A schematic diagram of the structure of a data migration system provided in an embodiment of the present application;
[0028] Figure 8 An interactive diagram of the fourth data migration method provided in an embodiment of the present application;
[0029] Fig. 9 A data migration diagram provided for an embodiment of the present application;
[0030] Fig.10 Migrate the display content of the system management interface for interactive tools;
[0031] Fig.11 A schematic diagram for reconfirmation;
[0032] Fig.12 A schematic diagram of a server structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0035] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.
[0036] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0037] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two. For example, multiple processing units refer to two or more processing units; multiple systems refer to two or more systems.
[0038] Database: A database is an ordered collection of structured information or data, generally stored in an electronic form in a computer or server. It is usually controlled by a database management system. In actual use, the database and database management software are collectively referred to as a database system. Through the database management software, users can add, delete, update, and / or obtain data in the database. The database management software can be installed on an electronic device, and users can add, delete, update, and / or obtain data in the database through the operation interface of the database management software. The database management software can also be installed on a server, and the operation interface of the database management software can be displayed on a display connected to the server. Users can add, delete, update, and / or obtain data in the database on the operation interface.
[0039] Structured Query Language (SQL): is a database query language and programming language, mainly used to manage data in the database, such as accessing data, querying data, or updating data. SQL statements are a language for operating databases. SQL statements include data definition language, data manipulation language, data query language, and data control language.
[0040] The data definition language is mainly used to define databases, data tables in the database, etc., including CREATE statements, ALTER statements, and DROP statements. The CREATE statement is used to create a database and / or a data table, the ALTER statement is used to modify the definition of a data table, etc., and the DROP statement is used to delete a database and / or a data table.
[0041] Data manipulation language is mainly used to add, modify and delete operations on the database, including INSERT statement, UPDATE statement and DELETE statement. INSERT statement is used to insert data, UPDATE statement is used to modify data, and DELETE statement is used to delete data.
[0042] Data query language is mainly used to query data. For example, users can use SELECT statements to query one or more data in the database.
[0043] Data control language is mainly used to control user access rights, including GRANT statement, REVOKE statement, COMMIT statement and ROLLBACK statement. GRANT statement is used to add permissions to users, REVOKE statement is used to revoke user permissions, COMMIT statement is used to commit transactions, and ROLLBACK statement is used to roll back transactions. At present, users often use SQL statements to manage database data through database objects. Database objects, also known as SQL entities, include data tables, views, columns, schemas, indexes, stored procedures, triggers, and functions. SQL entity names are identifiers. For example, the name of a data table is analyze_fdb, and analyze_fdb is an identifier. But in general, reserved words are not used as SQL entity identifiers.
[0044] Reserved words are special identifiers that are reserved in the database and used as part of the SQL syntax. It is understandable that in the database, reserved words are used to perform specific SQL statement operations. For example, in the Oracle database, the reserved word analyze is used to perform the "analyze" SQL statement operation. If a reserved word is used as an SQL entity identifier, the SQL entity cannot be recognized when performing an SQL operation. For example, if the reserved word analyze is used as an identifier for a data table, when performing an SQL operation, analyze can only be recognized as an "analysis" operation, and will not be recognized as a data table.
[0045] Different relational databases have different reserved word sets. A reserved word set refers to a collection of multiple reserved words in a database. For example, the reserved word set of the Oracle database adds reserved words used as part of the connect by syntax, the reserved word set of the MySQL database adds reserved words used as part of the limit syntax, and the reserved word set of the Postgresql database adds reserved words used as part of the lateral syntax.
[0046] When the data to be migrated needs to be sent for migration between two different databases, for example, the data to be migrated is migrated from the first database to the second database, and the SQL entity identifier of the data to be migrated in the first database is the same as a reserved word in the reserved word set in the second database, causing the migration to fail. For example, the SQL entity identifier of the data to be migrated in the first database is analyze, but analyze is a reserved word in the reserved word set in the second database. Users cannot migrate the data to be migrated from the first database to the second database.
[0047] Exemplarily, when the data to be migrated is migrated from the first database to the second database, "ERROR JDBC ExceptionReporter: 78-You have an error in your SQL syntax; check the manual that corresponds to your MySQLserver version for the right syntax to use near'Database reservedkeyword... " will be displayed on the display interface of the database management software corresponding to the second data, indicating that the migration of the data to be migrated has failed.
[0048] The related solution solves the migration failure problem by modifying the SQL entity identifier of the data to be migrated in the first database so that the modified SQL entity identifier does not belong to the reserved words in the second database. For example, if the data to be migrated in the first database is the analyze data table. Here, analyze is the identifier of the data table. The user can modify the SQL entity identifier of the data to be migrated in the first database from analyze to analyze_fdb. Here, analyze_fdb does not belong to the reserved words in the second database. In this way, the migration failure problem can be solved.
[0049] However, the related technology needs to sort out the source code of the data to be migrated in the first database. Specifically, all SQL statements corresponding to the data to be migrated in the first database are traversed to obtain the SQL statement to be changed. The SQL entity identifier contained in the SQL statement to be changed is the same as the reserved word in the second database. The SQL entity identifier in the SQL statement to be changed is changed so that the SQL entity identifier in the changed SQL statement is not a reserved word of the second database.
[0050] For example, the SQL statement to be changed is "Select xx from analyze where yy='cvc'". Among them, "analyze" is a reserved word of the second database. At this time, the user can change the SQL entity identifier "analyze" in the SQL statement to be changed to "analyze_fdb". "analyze_fdb" is not a reserved word of the second database. At this time, the SQL statement to be changed is changed to "Select xx fromanalyze_fdb where yy='cvc'", and the changed SQL statement does not include the reserved words in the second database. Thereby, the problem of migration failure when migrating the data to be migrated from the first database to the second database is solved. However, the related technology has a large intrusion on the migrated data, and when the amount of data is large, it takes a lot of time to traverse and change, and the data migration efficiency is low.
[0051] In view of the above problems, an embodiment of the present application provides a data migration method. Obtain reserved words to be deleted. The reserved words to be deleted refer to identifiers of the data to be migrated in the first database. When the first reserved word set of the second database includes the reserved words to be deleted, delete the reserved words to be deleted from the first reserved word set to obtain a second reserved word set. Replace the reserved word set in the second database with the second reserved word set, and migrate the data to be migrated from the first database to the second database replaced with the second reserved word set. It can be seen that the second reserved word set is the reserved word set after deleting the reserved words to be deleted, and the second reserved word set does not contain reserved words that cause the migration failure of the data to be migrated. Since the current reserved word set of the second database after replacement is the second reserved word set, that is, the second database after replacement does not contain reserved words that cause the migration failure of the data to be migrated, therefore, the migration success rate of migrating the data to be migrated from the first database to the second database can be improved to a certain extent.
[0052] In addition, the data migration method provided in the embodiment of the present application does not require modification of the SQL statements of the first database, thereby avoiding intrusion into the original data and avoiding the problem of low data migration efficiency caused by traversing all SQL statements when the amount of data is large.
[0053] The data migration method provided in the embodiment of the present application is fully and detailedly described below in conjunction with the accompanying drawings.
[0054] First combine Figure 1 , introduces the application scenarios of the data migration method provided in the embodiments of the present application.
[0055] See also Figure 1, which is a schematic diagram of an application scenario of a data migration method provided in an embodiment of the present application. Specifically, it involves a first database 120, a second database 130, a server 110 associated with the second database, and an interactive tool 140. The server 110 can access the first database 120 and the second database 130 through a network, and the server 110 and the interactive tool 140 can exchange information through the network. The first database 120 can be located on the server 110 or on other servers, and the present application does not specifically limit the location of the first database 120.
[0056] The interactive tool 140 is user-oriented. The interactive tool 140 may be an electronic device that deploys a data migration system, such as a mobile phone, a laptop, a wearable electronic device (e.g., a smart watch), a tablet computer, a server, a computer, etc. The user may perform data migration operations on the management interface of the data migration system of the interactive tool 140.
[0057] When the user performs a data migration operation on the management interface of the data migration system, the data migration system obtains the data to be migrated from the first database 120 , and migrates the data to be migrated from the first database 120 to the second database 130 .
[0058] In addition, the interactive tool 140 can also be a desktop computer, a display, etc. connected to the server 110 to achieve data migration together with the server 110. Optionally, the server 110 has built-in management software for the data migration system, and the interactive tool 140 displays the management interface of the data migration system. The user can perform data migration operations on the management interface displayed by the interactive tool 140, and the data migration system in the server obtains the request command to be migrated, obtains the data to be migrated from the first database 120, and migrates the data to be migrated from the first database 120 to the second database 130.
[0059] In actual use, in view of the problem that the database object identifier of the first database 120 to which the data belongs before the migration may be the same as the reserved word of the second database 130 to be migrated, resulting in the failure of data migration from the first database 120 to the second database 130, the data migration system executes the data migration method provided in the embodiment of the present application to obtain the reserved word to be deleted. The reserved word to be deleted is the SQL entity identifier of the data to be migrated in the first database 120. When the first reserved word set of the second database 130 includes the reserved word to be deleted, the reserved word to be deleted is deleted from the first reserved word set to obtain the second reserved word set. And the reserved word set in the second database 130 is replaced with the second reserved word set. Finally, the data to be migrated is migrated from the first database 120 to the second database 130 for storage.
[0060] Optionally, the data migration system can perform the data migration method provided in the embodiment of the present application after the data to be migrated is migrated from the first database to the second database and the migration fails. In addition, the data migration system can also perform the data migration method provided in the embodiment of the present application before the data to be migrated is migrated.
[0061] Optionally, the data migration system includes a lexical analyzer 1101, a replacer 1102 and a migrator 1103, the lexical analyzer 1101 is used to execute acquisition of reserved words to be deleted, and when the first reserved word set of the second database 130 includes the reserved words to be deleted, delete the reserved words to be deleted from the first reserved word set to obtain a second reserved word set.
[0062] The migrator 1103 is used to migrate the data to be migrated from the first database 120 to the second database 130. The replacer 1102 is used to replace the reserved word set of the second database 130.
[0063] It should be understood that Figure 1 The application scenarios shown are only examples. In actual application, the first database 120 and the second database 130 can be isomorphic databases, such as both are Oracle databases. The first database 120 and the second database 130 can also be heterogeneous databases, such as the first database 120 is an Oracle database and the second database 130 is a MySQL database. The first database 120 and the second database 130 can be relational databases or non-relational databases containing reserved words. The first database 120 and the second database 130 can be deployed on the same server or on different servers. The embodiment of the present application does not specifically limit the application scenario of the data migration method.
[0064] In actual use, the database object of the data to be migrated can be at least one of a table, a view, a column, a mode, an index, a stored procedure, a function, and a trigger. For example, the number of database objects of the data to be migrated can be one or more. The embodiment of the present application does not specifically limit the number and type of database objects of the data to be migrated.
[0065] In actual use, server 110 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as large databases and artificial intelligence platforms. When the above-mentioned server is a server cluster composed of multiple physical servers, or a distributed system, multiple physical servers can form a blockchain, and each physical server is a node on the blockchain. The physical type of the service area can be a rack server, a high-density server, a GPU server, a tower server, and can also be a blade server, a whole cabinet server, etc., which is not specifically limited in this application.
[0066] Combine the following Figure 2 , the data migration method provided in the embodiment of the present application is described.
[0067] See also Figure 2 , is a flow chart of the first data migration method provided in the embodiment of the present application. The method may include the following S21-S24:
[0068] S21: Obtain the reserved word to be deleted.
[0069] The reserved words to be deleted refer to the SQL entity identifiers of the data to be migrated in the first database. It is understandable that when the current reserved word set of the second database includes the reserved words to be deleted, if the user migrates the data to be migrated from the first database to the second database, the migration of the data to be migrated will fail.
[0070] In one practicable manner, the data migration system may obtain the reserved words to be deleted before migrating the data to be migrated.
[0071] Optionally, the user can execute the operation of inputting a statement of the reserved word to be deleted in the management interface of the data migration system, for example, the user inputs the Sp_delete_reserved_keyword('analyze') statement, and inputs the reserved word to be deleted analyze into the data migration system through the first interface. In this case, the user only needs to input the database object identifier of the data to be migrated belonging to the first database, so that the digital migration system can obtain the reserved word to be deleted and execute the operation of deleting the reserved word to be deleted, which is simple and flexible.
[0072] Optionally, when the user performs a migration operation of the data to be migrated in the management interface of the data migration system, a dialog box pops up in the management interface. The user can enter the reserved word to be deleted in the dialog box. The reserved word to be deleted is input into the data migration system through the first interface.
[0073] Example description: See Figure 3 , is a schematic diagram of a data migration system provided in an embodiment of the present application for obtaining reserved words to be deleted. Figure 3 (a) is a schematic diagram of the management interface of a data migration system on a mobile phone. When the user performs the operation of migrating the analyze data table from the first database to the second database, the management interface displays a dialog box for entering the reserved word to be deleted, and the dialog box prompts the user to enter the reserved word to be deleted "Please enter the reserved word string to be deleted". Figure 3 As shown in (b) of FIG. 1 , the user can input the reserved word to be deleted analyze in the reserved word to be deleted dialog box, and click the confirmation button, and the reserved word to be deleted analyze is input into the data migration system through the first interface.
[0074] It can be seen from this that compared with the user entering the reserved word to be deleted statement in the management interface, the user can enter the reserved word to be deleted in the dialog box, which is more user-friendly.
[0075] Optionally, the user can enter multiple reserved words to be deleted in the dialog box. Multiple reserved words to be deleted can be separated by commas, or multiple reserved words to be deleted can be separated by semicolons or other separators. For example, see Figure 3 In (c), the user can enter the reserved words to be deleted, analyze1, analyze2, ..., analyzen, in the reserved words to be deleted dialog box. Where n is a positive integer ≥ 2. The reserved words to be deleted dialog box includes a prompt message, specifically "Please enter the reserved words to be deleted string, multiple reserved words to be deleted, please separate them with commas." Compared with entering one reserved word to be deleted each time and performing a data migration, the user enters multiple reserved words to be deleted at a time, which has better usability and higher processing efficiency.
[0076] Optionally, considering that there may be input errors in the input, when the user performs a migration operation of the data to be migrated, the data migration system may automatically obtain the reserved words to be deleted by means of a crawler or the like.
[0077] In one achievable manner, the data migration system may obtain the reserved words to be deleted after the migration of the data to be migrated fails.
[0078] Optionally, when the migration of the data to be migrated fails, an operation of entering a statement of reserved words to be deleted can be executed in the management interface of the data migration system. Alternatively, when the migration of the data to be migrated fails, a dialog box pops up in the management interface. The user can enter the reserved words to be deleted in the dialog box. The reserved words to be deleted are input to the data migration system through the first interface. Optionally, the user can enter multiple reserved words to be deleted in the dialog box, and the multiple reserved words to be deleted can be separated by commas, or the multiple reserved words to be deleted can be separated by semicolons, or other separators.
[0079] In addition, considering that there are input errors in the input, when the migration of the data to be migrated fails, the data migration system can first obtain the reserved words to be deleted from the data migration exception log stored in the server 110 by means of a crawler or the like. At this time, the reserved words to be deleted are the reserved words that cause the data migration failure. The first interface sends the obtained reserved words to be deleted to the data migration system.
[0080] The server 110 may also obtain the reserved words to be deleted in various ways, and this application does not specifically limit the obtaining method.
[0081] S22: When the first reserved word set of the second database includes the reserved word to be deleted, the reserved word to be deleted is deleted from the first reserved word set to obtain a second reserved word set.
[0082] The first reserved word set may be the original reserved word set in the second database, or the remaining reserved word set after deleting some reserved words from the original reserved word set in the second database. The first reserved word set may be the reserved word set in the second database at the current moment, or the reserved word set in the second database at the previous moment, etc. This application does not limit the reserved word range and existence time of the first reserved word set.
[0083] If the first reserved word set includes the reserved word to be deleted, the first reserved word set is used as the current reserved word set of the second database. If the user migrates the data to be migrated from the first database to the second database, the migration of the data to be migrated will fail. Therefore, when the first reserved word set includes the reserved word to be deleted, the database migration system deletes the reserved word to be deleted from the first reserved word set to obtain the second reserved word set.
[0084] Exemplary explanation 1: Assume that the first reserved word set D1 = {d1, d2, d3, d4, h1, h2, h3, m1, m2, m3}, the reserved word to be deleted is d1, and the obtained second reserved word set is D1' = {d2, d3, d4, h1, h2, h3, m1, m2, m3}.
[0085] If there are multiple reserved words to be deleted, the data migration system determines whether the multiple reserved words to be deleted all belong to the first reserved word set. If the multiple reserved words to be deleted all belong to the first reserved word set, the data migration system deletes all the reserved words to be deleted from the first reserved word set.
[0086] Exemplary description 2: Assume that the first reserved word set D1 = {d1, d2, d3, d4, h1, h2, h3, m1, m2, m3}, and the reserved words to be deleted are d1, d2 and h1. Since the reserved words to be deleted all belong to the first reserved word set D1, all the reserved words to be deleted are deleted from D1, and the second reserved word set obtained is D1' = {d3, d4, h2, h3, m1, m2, m3}.
[0087] If the plurality of reserved words to be deleted do not all belong to the first reserved word set, the digital migration system deletes the reserved words to be deleted that belong to the first reserved word set from the first reserved word set.
[0088] Exemplary explanation 3: Assume that the first reserved word set D1 = {d1, d2, d3, d4, h1, h2, h3, m1, m2, m3}, and the reserved words to be deleted are d1, d2 and h4. Among them, the reserved words to be deleted d1 and d2 belong to the first reserved word set, and d1 and d2 are deleted from the first reserved word set, and the second reserved word set obtained is D1' = {d3, d4, h1, h2, h3, m1, m2, m3}.
[0089] If the first reserved word set does not include the reserved words to be deleted, the first reserved word set does not need to be processed, and the data migration system uses the first reserved word set as the second reserved word set. For example, before the data to be migrated is migrated, the user inputs the reserved words to be deleted into the data migration system, and the first reserved word set in the data migration system may not include the reserved words to be deleted.
[0090] It can be seen that the second reserved word set does not include the reserved word to be deleted, that is, the second reserved word set does not contain the same reserved word as the SQL entity identifier of the data to be migrated in the first database.
[0091] S23: Replace the first reserved word set in the second database with the second reserved word set.
[0092] In the embodiment of the present application, the first reserved word set in the second database is replaced with the second reserved word set, so that the replaced second database does not contain the same reserved words as the SQL entity identifiers of the data to be migrated in the first database. This eliminates the risk that the reserved words in the second database are the same as the SQL entity identifiers of the data to be migrated in the first database, and improves the migration success rate of the data to be migrated.
[0093] The replacement method may be: the data migration system first deletes the first reserved word set in the second database, and then adds the second reserved word set to the corresponding position of the second database. Alternatively, the data migration system first adds the second reserved word set to the corresponding position of the second database, and then deletes the first reserved word set in the second database.
[0094] In addition, during the replacement, the first reserved word set in the second database may have the same name as the second reserved word set. For example, if the second reserved word set is D1", the first reserved word set in the second database before the replacement is also D1". There may be a conflict during the replacement. In this case, the data migration system may replace the first reserved word set in the second database with the second reserved word set, so that the reserved word set in the second database is the second reserved word set.
[0095] The replacement method of the embodiment of the present application belongs to soft replacement. The data migration system only needs to replace the reserved word set on the server side, and does not require the user to re-release the database program corresponding to the second database on the server side. Therefore, the soft replacement method of the embodiment of the present application has the characteristics of low risk, high stability, and less time consumption, compared with the re-release involving a long multi-point test cycle and the need to modify the stability risk of reserved words.
[0096] Optionally, if the first reserved word set does not include the reserved words to be deleted, and the first reserved word set is the reserved words in the second database before replacement, the reserved word set of the second database does not need to be replaced, and the process directly proceeds to step S24, where the data migration system migrates the data to be migrated from the first database to the second database.
[0097] S24: Migrate the data to be migrated from the first database to the second database.
[0098] In one achievable manner, after the second database completes replacing the second reserved word set, the database migration system automatically migrates the data to be migrated from the first database to the second database.
[0099] Optionally, when the second database replaces the second reserved word set, the management interface of the data migration system displays a prompt box, and the user can perform operations in the prompt box. When the user performs the continue migration operation in the prompt box, the data migration system migrates the data to be migrated from the first database to the second database.
[0100] Exemplary description: A prompt box "Replacement completed, do you want to continue the migration operation" is displayed on the management interface of the data migration system, and "Yes" and "No" selection boxes are displayed. When the user selects "Yes", the data migration system migrates the data to be migrated from the first database to the second database. When the user selects "No", the data migration system ends the migration process.
[0101] In yet another achievable manner, when the second database does not need to replace the reserved word set, the data migration system directly migrates the data to be migrated from the first database to the second database.
[0102] When the data to be migrated is migrated from the first database to the replaced second database, for example, the analyze data table is migrated from the first database to the replaced second database, since the current reserved word set of the second database is D1 = {d1, d2, d3, d4, m1, m2}, where d1, d2, d3, d4, m1, m2 are different reserved words. The second database does not have the same reserved words as analyze, so when the analyze data table is migrated from the first database to the second database, the problem of migration failure caused by the same current reserved word set of analyze and the second database can be avoided.
[0103] The data migration method provided by the embodiment of the present application. The method first obtains the reserved words to be deleted of the data to be migrated, and when the first reserved word set of the second database includes the reserved words to be deleted, deletes the reserved words to be deleted from the first reserved word set to obtain the second reserved word set, replaces the first reserved word set in the second database with the second reserved word set, and then migrates the data to be migrated from the first database to the second database replaced with the second reserved word set. It can be seen that the second reserved word set is the reserved word set after deleting the reserved words to be deleted, and the second reserved word set does not contain the reserved words that cause the migration failure of the data to be migrated. Since the current reserved word set of the second database after replacement is the second reserved word set, that is, the second database after replacement does not contain the reserved words that cause the migration failure of the data to be migrated, therefore, the migration success rate of migrating the data to be migrated from the first database to the second database can be improved.
[0104] In addition, the embodiment of the present application also provides a second data migration method.
[0105] See also Figure 4 , is a flow chart of a second data migration method provided in an embodiment of the present application, which is applied after the migration of the data to be migrated fails. In an embodiment of the present application, the first reserved word set may be the reserved word set at the current moment in the second database, and the method specifically includes the following steps:
[0106] S41: Load the first blacklist set.
[0107] The first blacklist set is a blacklist reserved word set. In an embodiment of the present application, the blacklist reserved words are reserved words that belong to the original reserved word set in the second database but do not belong to the first reserved word set. It is understandable that the first blacklist set can be an empty set that does not contain any reserved words. The first blacklist set can also be at least one blacklist reserved word set.
[0108] The first blacklist set can be dynamically adjusted, for example, by adding reserved words to be deleted. In this case, the data migration system will trigger an operation of deleting the reserved words to be deleted in the first blacklist set from the first reserved word set.
[0109] Exemplary description: The first blacklist set is H1 = {h1, h2, h3}, where h1, h2, h3 represent three different reserved words. Add reserved word h4, and the first blacklist set H1 is changed to H1 = {h1, h2, h3, h4}. The data migration system will delete the reserved word h4 from the first reserved word set.
[0110] The above-mentioned method and number of adding reserved words are only for illustrative purposes, and the present application does not specifically limit the method and number of addition. The present application does not limit the position of adding the added reserved words in the first blacklist set, for example, the reserved words can be added to the first few element positions in the first blacklist set, and the reserved words of other element positions are moved back. Those skilled in the art can adjust as needed.
[0111] In the embodiment of the present application, the reserved words of the first blacklist set exist in the form of a string, that is, the first blacklist set is a set of strings, which can be represented in the form of a list or a hash table, etc. Among them, the hash table is a data structure accessed according to the key string value. The first blacklist set is represented in the form of a hash table, which can quickly find the reserved words required in the first blacklist set and improve the processing speed.
[0112] S42: Obtain the reserved word to be deleted.
[0113] Step S42 is the same as step S21 and will not be repeated here.
[0114] It should be noted that step S41 and step S42 do not have a sequential relationship. S41 can be performed first and then S42, or S42 can be performed first and then S41, or S41 and S42 can be performed simultaneously.
[0115] S43: Determine whether the reserved word to be deleted is a blacklist reserved word in the first blacklist set. If not, optionally, S44 can be executed, or S45 can be executed, or it is prompted that the reserved word to be deleted is not the reason for the failure of the migration of the data to be migrated, and other means are needed for analysis. If so, S49 is executed.
[0116] As mentioned above, the blacklist reserved words are reserved words that belong to the original reserved word set in the second database but do not belong to the first reserved word set. It is understandable that the first reserved word set does not include the blacklist reserved words in the first blacklist set. If the reserved word to be deleted belongs to the blacklist reserved word in the first blacklist set, it means that the first reserved word set does not contain the reserved word to be deleted, and at this time, the first reserved word set does not need to be deleted.
[0117] In the case where the reserved word to be deleted belongs to the reserved word in the first blacklist set, it means that the current reserved word set of the second database does not contain the reserved word to be deleted. At this time, the reserved word to be deleted is not the reason for the failure of the migration of the data to be migrated, and other means are needed for analysis. At this time, the management interface of the data migration system can pop up a prompt box to prompt the user that the reserved word warning has been deleted.
[0118] When the reserved word to be deleted does not belong to the blacklist reserved words in the first blacklist, that is, the first reserved word set may still contain the reserved word to be deleted. At this time, the reason for the failure of the data to be migrated may be that the current reserved word set of the second database includes the reserved word to be deleted. The data migration system can improve the migration success rate of the data to be migrated by deleting the reserved word to be deleted from the first reserved word set.
[0119] Exemplary description 1: Assume that the first blacklist set H0 = {m, n, a, a1, a2}, indicating that different blacklist reserved words m, n, a, a1 and a2 do not belong to the current reserved word set of the second database, that is, the blacklist reserved words have been deleted from the current reserved word set of the second database. When the reserved word to be deleted is h1, h1 does not belong to the first blacklist set H0 at this time and needs to be deleted from the first reserved word set. When the deleted reserved word is a1, a1 belongs to the first blacklist set, indicating that the reserved word to be deleted a1 is not the reason for the failure of the migration of the data to be migrated, and the data migration system can output a warning that the reserved word has been deleted.
[0120] Exemplary description 2: When there are multiple reserved words to be deleted, such as h1 and a1, the first blacklist set H0 = {m, n, a, a1, a2}, indicating that different blacklist reserved words m, n, a, a1 and a2 do not belong to the current reserved word set of the second database. Among them, the reserved word a1 to be deleted belongs to the first blacklist set H0, and the reserved word h1 to be deleted does not belong to the first blacklist set. At this time, the reserved word h1 to be deleted may be the reason for the failure of the migration of the data to be migrated, and the reserved word h1 to be deleted needs to be deleted from the first reserved word set. If the reserved words to be deleted are a1 and a2, and the reserved words a1 and a2 to be deleted both belong to the first blacklist set, the data migration system can output a warning that the reserved word has been deleted.
[0121] That is, when there are multiple reserved words to be deleted, and when all of the multiple reserved words to be deleted belong to the first blacklist set, the data migration system outputs a warning that the reserved words have been deleted.
[0122] Optionally, S44: determine whether the reserved word to be deleted is a reserved word in the pre-loaded whitelist set. If not, execute S45; if yes, execute S410.
[0123] In actual use, the second database may contain some reserved words that cannot be deleted. When these reserved words are deleted, the second database may be damaged, such as making some functions invalid or crashing the existing second database. Therefore, the embodiment of the present application may set a whitelist set in the data migration system, and save the reserved words that cannot be deleted into the whitelist set. The data in the whitelist set is a set of strings, which may be represented in the form of a list or a hash table.
[0124] In an embodiment of the present application, the reserved words in the whitelist set include a first reserved word and a second reserved word. The first reserved word belongs to the reserved words obtained from the intersection of the reserved word sets in multiple databases. For example, n databases are selected, namely database A1, database A2, ... database An (n≥2). The reserved word set of database A1 is A1 = {a, b, c, d, e, f}, the reserved word set of database A2 is A2 = {a, b, c, d, m, n}, ..., the reserved word set of database An is A1 = {a, n, n, p, e, f}, and A1∩A2∩...∩An = {a}, then a is the first reserved word and is stored in the whitelist set. In the above reserved word set, a, b, c, d, e, f, m, n, p... are different reserved words.
[0125] The second reserved word is a reserved word that causes the existing function of the second database to fail after deletion, or a reserved word that causes the second database to crash after deletion. The data migration system can obtain the second reserved word through prior experience or other means. It is understandable that if the data migration system deletes the reserved words in the whitelist set, it will damage the original function of the second database. Therefore, the data migration system first determines whether the reserved word to be deleted is in the pre-acquired whitelist table. If it is in the whitelist table, it outputs a warning that it cannot be deleted, and the user needs to handle it in other ways. For example, the user can modify the SQL entity identifier of the data to be migrated in the first database so that the modified SQL entity identifier is not a reserved word in the second database.
[0126] Optionally, the data migration system traverses all reserved words in the whitelist set. If there is a reserved word that is the same as the reserved word to be deleted, it means that the reserved word to be deleted belongs to the whitelist set. Otherwise, the reserved word to be deleted does not belong to the whitelist set.
[0127] When there is one reserved word to be deleted, if there is a reserved word identical to the reserved word to be deleted in the white list, the data migration system outputs a warning. Otherwise, the data migration system adds the reserved word to be deleted to the first black list for deletion.
[0128] For example: Assume that the whitelist set is B = {m1, m2, a, c, e}, where m1, m2, a, c, and e represent different reserved words. The reserved word to be deleted is a, a∈B, then a belongs to the reserved words in the whitelist set and cannot be deleted. If the reserved word to be deleted is b, Then the deletion of b does not affect the normal operation of the second database system and can be deleted normally.
[0129] When there are multiple reserved words to be deleted, the data migration system adds the reserved words to be deleted that are not in the white list set to the first black list. And when all the reserved words to be deleted are in the white list set, the data migration system outputs a warning that the deletion cannot be performed.
[0130] Example description: Assume that the whitelist set is B = {m1, m2, a, c, e}, and the reserved words to be deleted are m1, b and a, a∈B, m1∈B, At this time, b is added to the first blacklist set.
[0131] In the embodiment of the present application, the data migration system further judges the reserved words to be deleted by introducing a whitelist mechanism to avoid deleting the reserved words to be deleted, which may cause the second database system to fail to function or crash. S45: Add the reserved words to be deleted to the first blacklist set to obtain the second blacklist set.
[0132] When the data migration system determines that the reserved word to be deleted is not a reserved word in the first blacklist set and does not belong to the whitelist set, the data migration system adds the reserved word to be deleted to the first blacklist set. In the embodiment of the present application, the first blacklist after adding the reserved word to be deleted is called the second blacklist set.
[0133] The embodiments of the present application can be added in a variety of ways, such as the data migration system adds the reserved words to be deleted to a preset position, and exemplarily adds the reserved words to be deleted to the next position of the last reserved word. For example, the first blacklist set is H0 = {m, n, a, a1, a2}, and the reserved word p to be deleted does not belong to the first blacklist set, nor does it belong to the whitelist set B = {m1, m2, a, c, e}, then the reserved word p to be deleted is placed in the next position of the last reserved word of H0, and the first blacklist set is H1 = {m, n, a, a1, a2, p}. Or the data migration system adds the reserved words to be deleted to the first n bits, and shifts the other reserved words back by n bits, n≥1 and n is a positive integer, and the value of n is the same as the number of reserved words to be deleted. The first blacklist set obtained is H1 = {p, m, n, a, a1, a2}. Among them, the above m, n, a, a1, a2, m1, m2, c, e, p are different reserved words. The embodiments of the present application do not specifically limit the adding method.
[0134] It can be understood that the second blacklist includes reserved words to be deleted, and the reserved words to be deleted will not affect the function of the second database.
[0135] Optionally, to improve the usability of the data migration system, after adding the reserved word to be deleted to the first blacklist set to obtain the second blacklist set, the data migration system outputs a deletion success prompt through the first interface. The user can perform the deletion operation according to the deletion success prompt displayed on the management interface of the data migration system.
[0136] S46: Deleting the reserved words to be deleted in the second blacklist set from the first reserved word set in the second database to obtain a second reserved word set.
[0137] Optionally, when the reserved words to be deleted are added to the first blacklist set, after the addition is completed, the data migration system automatically enters the operation of deleting the reserved words to be deleted in the second blacklist set from the first reserved word set of the second database.
[0138] Optionally, when the reserved word to be deleted is added to the first blacklist set, after the addition is completed, the data migration system outputs a deletion success prompt through the first interface. The user can perform a deletion operation according to the deletion success prompt displayed on the management interface of the data migration system, and enter the operation of deleting the reserved word to be deleted in the second blacklist set from the first reserved word set of the second database.
[0139] The first reserved word set deletes the reserved words to be deleted in the second blacklist set, and the deleted first reserved word set is also called the second reserved word set. For example, the first reserved word set is D1={d1, d2, d3, d4, h1, h2, h3, m1, m2, m3}, where d1, d2, d3, d4, h1, h2, h3, m1, m2 and m3 are used to indicate different reserved words. The reserved word to be deleted in the second blacklist set is d1, then the second reserved word set is D1'={d2, d3, d4, h1, h2, h3, m1, m2, m3}.
[0140] Optionally, the data migration system may traverse all reserved words in the first reserved word set, mark all reserved words in the first blacklist set, for example, with a signal mark, and delete all reserved words marked as "signal" in the first reserved word set.
[0141] Exemplary description: Assume that the first reserved word set D1 = {d1, d2, d3, d4, h1, h2, h3, m1, m2, m3}, where d1, d2, d3, d4, h1, h2, h3, m1, m2 and m3 are used to indicate different reserved words. The reserved words in the first blacklist set are H1 = {h1, h2, h3}. The data migration system traverses all D1s, identifies the reserved words belonging to the reserved words in H1, and obtains the identified first reserved word set, D1'={d1, d2, d3, d4, h1(signal), h2(signal), h3(signal), m1, m2, m3}, deletes all reserved words marked as "signal", and obtains the deleted first reserved word set D1"={d1, d2, d3, d4, m1, m2, m3}. The deleted first reserved word set does not include the reserved words that are the same as the database object identifier of the data to be migrated in the first database, that is, it does not include the reserved words to be deleted.
[0142] This deletion method can delete all reserved words belonging to the first blacklist set in the first reserved word set, avoiding the risk of conflict between the second reserved word set and the SQL entity identifier of the data to be migrated in the first database due to unclean deletion.
[0143] It is worth noting that the above deletion method is only for illustration, and this application does not specifically limit the deletion method.
[0144] It can be seen that the second reserved word set does not include the reserved words in the first blacklist set, that is, does not include the reserved words that are the same as the SQL entity identifier of the data to be migrated in the first database.
[0145] S47: Replace the reserved word set of the second database with the second reserved word set.
[0146] In an embodiment of the present application, the data migration system first deletes the reserved word set in the second database, and then adds the second reserved word set to the corresponding position of the second database. Alternatively, the data migration system first adds the second reserved word set to the corresponding position of the second database, and then deletes the first reserved word set of the second database before the replacement.
[0147] S48: Migrate the data to be migrated from the first database to the second database again.
[0148] Step S48 is the same as step S24 and will not be discussed again here.
[0149] S49: The data migration system outputs a warning that a reserved word has been deleted.
[0150] When all the reserved words to be deleted belong to the blacklist reserved words in the first blacklist, it means that the current reserved word set of the second database does not contain the reserved words to be deleted. At this time, the reserved words to be deleted are not the cause of the failure of the migration of the data to be migrated. The user needs to analyze other reasons for the failure of the migration of the data to be migrated, such as the data format of the data to be migrated in the first database is incompatible with the data format of the second database, etc., to solve the problem of the failure of the migration of the data to be migrated in a targeted manner.
[0151] Optionally, when all the reserved words to be deleted belong to the blacklist reserved words in the first blacklist, the data migration system outputs a deleted reserved word warning through the first interface, and displays the deleted reserved word warning on the management interface of the data migration system.
[0152] S410: The data migration system outputs a warning that it cannot be deleted.
[0153] When all the reserved words to be deleted belong to the white list set, it means that the second database deletes the reserved words to be deleted. At this time, the second database cannot operate normally.
[0154] Therefore, when all the reserved words to be deleted belong to the whitelist, the data migration system outputs a deletion failure warning through the first interface, and displays the deletion failure warning on the management interface of the data migration system.
[0155] In an embodiment of the present application, the first blacklist set is used to save the reserved words that have been deleted in the first reserved word set of the second database. When the reserved words to be deleted belong to the blacklist reserved words in the first blacklist set, the deletion operation is no longer performed, and the deletion process is omitted. In addition, by introducing a whitelist table protection mechanism, the embodiment of the present application avoids the problem that the user arbitrarily deletes the reserved words in the second database, causing the second database to fail to operate normally, thereby improving the stability of the second database system. In addition, the embodiment of the present application displays output alarms and other prompts on the display interface of the data migration system. The user can intuitively determine the relationship between the SQL entity identifier of the data to be migrated in the first database and the reserved word set in the second database, and then perform subsequent operations based on this relationship.
[0156] See also Figure 5 , is a flow chart of a third data migration method provided in an embodiment of the present application. The method is applied before the data to be migrated is migrated from the first database to the second database. The method specifically includes:
[0157] S51: Obtain the reserved word to be deleted.
[0158] Optionally, when the user triggers an operation to migrate the data to be migrated from the first database to the second database, the data migration system obtains the reserved words to be deleted. Alternatively, before the user triggers an operation to migrate the data to be migrated from the first database to the second database, the data migration system obtains the reserved words to be deleted. The reserved words to be deleted are SQL entity identifiers of the data to be migrated in the first database.
[0159] Exemplarily, the user can input the reserved word to be deleted in the management interface of the data migration system, for example, input the Sp_delete_reserved_keyword (reserved word string to be deleted) statement, or directly input the reserved word to be deleted, so as to input the reserved word to be deleted into the data migration system through the first interface to perform the deletion operation.
[0160] In an embodiment of the present application, the first interface is used to send the reserved words to be deleted of the management interface to the data migration system. In addition, the first interface is also used to send information of the data migration system, such as a deleted warning or a non-reserved word warning, to the management interface for display.
[0161] It is understandable that the reserved word to be deleted is the SQL entity identifier of the data to be migrated in the first database. Since the data migration system has not yet performed data migration, the data migration system cannot determine whether the reserved word to be deleted is a reserved word in the second database, and whether it will cause data migration failure. Therefore, the data migration system needs to first determine whether the reserved word to be deleted is a reserved word in the second database.
[0162] S52: Load the first blacklist set.
[0163] The implementation of step S52 is the same as step S41 and will not be discussed here.
[0164] S53: Determine whether the reserved word to be deleted is a reserved word in the second database. If so, execute S54 or S55, or flash the reserved word to be deleted from the reserved word set of the second database to obtain the second reserved word set, and then execute S58. Otherwise, execute S512.
[0165] The reserved words to be deleted may be reserved words in the second database, or may not be reserved words in the second database. For reserved words not in the second database, data migration will not be affected, so there is no need to perform the process of adding them to the first blacklist set.
[0166] Therefore, in actual use, the data migration system may first determine whether the reserved word to be deleted is a reserved word in the second database.
[0167] If the reserved word to be deleted does not belong to the reserved words in the second database, it means that the reserved word to be deleted will not cause the migration of the data to be migrated to fail. At this time, the data migration system does not need to perform subsequent deletion operations, and can directly trigger the user to perform the operation of migrating the data to be migrated from the first database to the second database.
[0168] Optionally, when the reserved word to be deleted does not belong to the reserved words in the second database, the data migration system outputs a non-reserved word warning through the first interface and displays it on the management interface of the data migration system. At this time, the user can directly perform the operation of migrating the data to be migrated from the first database to the second database.
[0169] If the reserved word to be deleted is a reserved word in the second database, it means that the reserved word to be deleted may cause the migration of the data to be migrated to fail. Therefore, a deletion operation is required.
[0170] By judging whether the reserved words to be deleted belong to the reserved words in the second database, it is possible to avoid adding all the reserved words to be deleted to the first blacklist set, thereby preventing the first blacklist set from containing too many reserved words and affecting the deletion efficiency.
[0171] Optionally, when there is one reserved word to be deleted, the data migration system directly determines whether the reserved word to be deleted is a reserved word in the second database, and further determines whether to add the reserved word in the second database to the first blacklist set for deletion. Otherwise, the data migration system outputs a warning that it is not a reserved word.
[0172] Exemplary explanation: if the reserved word to be deleted is h4, the original reserved word set D0 in the second database = {a1, a2, a3, b1, b2, b3, m1, m2, m3, h1, h3}, where a1, a2, a3, b1, b2, b3, m1, m2, m3, h1, h3 are different reserved words. Therefore, h4 does not belong to the reserved words of the second database and does not need to be added to the first blacklist set. If the reserved word to be deleted is h1, h1∈D0, then there is a possibility that h1 will be added to the first blacklist set for deletion, and further judgment is required.
[0173] Optionally, when there are multiple reserved words to be deleted, the data migration system determines whether the multiple reserved words to be deleted are all reserved words in the second database. When there is a reserved word to be deleted that is a reserved word in the second database, the database migration system will perform a subsequent judgment on the reserved word to be deleted that is a reserved word in the second database to determine whether to add it to the first blacklist set.
[0174] Exemplary description: If there are multiple reserved words to be deleted, such as h1, h2, h3 and h4, the reserved words in the second database form a reserved word set D2 = {a1, a2, a3, b1, b2, b3, m1, m2, m3, h1, h3}. h1∈D2, h3∈D3, At this time, h2 and h4 perform subsequent judgment to determine whether to add the reserved words to be deleted belonging to the reserved words of the second database to the existing first blacklist set.
[0175] When the reserved words to be deleted do not belong to the reserved words in the second database, the subsequent deletion and replacement operations are no longer performed.
[0176] S54: Determine whether the reserved word to be deleted is a blacklist reserved word in the first blacklist set. If so, execute S55. Otherwise, execute S510.
[0177] S55: Determine whether the reserved word to be deleted is a reserved word in the pre-loaded whitelist set. If not, execute S56; if yes, execute S511.
[0178] S56: Add the reserved word to be deleted to the first blacklist set to obtain a second blacklist set.
[0179] Steps S54 to S56 are the same as steps S43 to S45 and will not be discussed here.
[0180] S57: Deleting the reserved words to be deleted in the second blacklist set from the first reserved word set in the second database to obtain a second reserved word set.
[0181] The specific deletion method is the same as step S46 and will not be discussed here.
[0182] When the reserved words to be deleted are deleted, the data migration system may further perform a confirmation operation to confirm whether the reserved words to be deleted have been deleted.
[0183] Method 1: The data migration system directly outputs the deleted list through the second interface and displays the deleted list on the management interface of the data migration system. The user can check the deleted list on the management interface to determine whether the data migration system has successfully deleted the reserved words to be deleted.
[0184] Method 2: When the reserved words to be deleted are deleted, the management interface of the data migration system pops up a successful deletion prompt. The user can enter the following statement in the interface for script input in the data migration system to confirm. The statement is: Sp_show_deleted_reserved_keyword(). There are no input parameters, which is used to display the reserved words that have been deleted in the current system. The data migration system obtains the display request sent by the user through the second interface, and sends the deleted list to the management interface of the data migration system through the second interface for display. The user can click the "Confirm" and other selection boxes to perform subsequent replacement operations.
[0185] The above confirmation methods are only schematic representations, and those skilled in the art may set the second interface and / or display content, etc. as needed.
[0186] In the embodiment of the present application, the data migration system can avoid directly entering the replacement operation when the first reserved word is unsuccessful in deletion by reconfirming the operation, thereby further improving the migration success rate of the data to be migrated.
[0187] S58: Replace the reserved word set of the second database with the second reserved word set.
[0188] S59: Migrate the data to be migrated from the first database to the second database.
[0189] S510: Output a warning indicating that a reserved word has been deleted.
[0190] S511: Output cannot delete warning.
[0191] Steps S58 to S511 are the same as steps S47 to S410 and will not be discussed again here.
[0192] S512: Output is not a reserved word warning.
[0193] Optionally, the data migration system can output a non-reserved word warning through the first interface and display it on the management interface of the data migration system. The user directly performs the operation of migrating the data to be migrated from the first database to the second database according to the displayed content of the management interface.
[0194] The following uses Oracle database and cloud database as examples to introduce the implementation of the data migration method provided in the embodiments of the present application.
[0195] In the embodiment of the present application, the SQL entity identifier of the data to be migrated in the Oracle database is a1. The data migration direction is from the Oracle database to the cloud database.
[0196] See also Figure 6 , which is a schematic diagram of the data migration process provided in an embodiment of the present application.
[0197] like Figure 6 (a) in FIG. 1 shows the data status of the Oracle database and the cloud database before the data to be migrated is migrated. The data of the Oracle database includes a1 data table, a2 data table, a3 data table, ... an data table (n is a positive integer). The cloud database does not include the data of the Oracle database.
[0198] The user first logs in to the data migration system through the interactive tool 140. Exemplary: the user opens a browser on the interactive tool 140, enters "http: / / data migration system access address" in the address bar, and opens the login interface of the data migration system. The user enters the user name and password in the login interface, clicks login, and enters the data migration system. In the management interface of the data migration system. The user performs the data migration operation of migrating the data to be migrated from the Oracle database to the cloud database in the management interface of the data migration system.
[0199] Optionally, when the user performs a migration operation on the data to be migrated, directly obtain the following Figure 6 The result shown in (b) indicates that the migration is successful. Figure 6 (b) in FIG. 1 shows the data status of the Oracle database and the cloud database after the data to be migrated is migrated. The cloud database includes the data table a1 of the data to be migrated.
[0200] When a migration operation fails, the management interface may also display "ERROR JDBC ExceptionReporter: 78-You have an error in your SQL syntax; check the manual that corresponds toyour MySQL server version for the right syntax to use near'Database reservedkeyword... ", indicating that the migration failed.
[0201] Optionally, when the user performs a migration operation on the data to be migrated, the management interface of the data migration system displays a prompt box for entering the reserved words to be deleted. Figure 6 As shown in (c) in the figure, the user can enter the reserved word a1 to be deleted in the prompt box. Figure 7 , is a schematic diagram of a data migration system structure provided by an embodiment of the present application, which specifically includes: a lexical analyzer 701, a reserved word change interface 702, a replacer 703 and a migrator 704. The reserved word change interface 702 includes a first interface and a second interface.
[0202] The first interface is Sp_delete_reserved_keyword(word string), wherein the input parameter wordstring is in the form of a string, which can be one reserved word to be deleted or multiple reserved words to be deleted. The user can enter the reserved word to be deleted in the management interface of the data migration system, or enter the Sp_delete_reserved_keyword(word string) statement for the reserved word to be deleted, and input the reserved word to be deleted into the data migration system through the first interface. The user can also enter the Sp_delete_reserved_keyword(wordstring) statement in the script input interface of the data migration system, and input the reserved word to be deleted into the data migration system through the first interface. The first interface is used to interact with the management interface of the data migration system, output the deletion results, and display them in the management interface. Among them, the deletion results include deletion exception warnings such as deletion warnings, inability to delete warnings, and not reserved word warnings, and deletion success prompts.
[0203] The second interface is Sp_show_deleted_reserved_keyword(), which has no input parameters. It is used to display the reserved words that have been deleted in the current second database. The user can enter the Sp_show_deleted_reserved_keyword() statement in the management interface of the data migration system or the script input interface. The data migration system obtains the request to display the deleted reserved words through the second interface, and outputs the deleted reserved words list through the second interface and displays it in the management interface.
[0204] The lexical analyzer 701 is used to delete the reserved words to be deleted from the first reserved word set of the second database. The replacer 703 is used to replace the reserved word set of the second database with the deleted first reserved word set. The migrator 704 is used to execute the migration of the data to be migrated from one database to another database.
[0205] The following is the above Figure 7 As an example, the database migration system shown in Figure 8 The data migration method flow chart shown in FIG. 1 details the fourth data migration method provided in an embodiment of the present application.
[0206] See also Figure 8 FIG. 1 is an interactive diagram of the fourth data migration method provided in the embodiment of the present application. The method specifically includes the following steps:
[0207] S81: The lexical analyzer 702 loads the first blacklist set.
[0208] like Fig. 9As shown, a data migration schematic diagram provided by an embodiment of the present application is shown, wherein the loaded first blacklist set H0 = {a4, c3, c4, ... cn}, wherein n is a positive integer, and a4, c3, c4, ... cn are different reserved words in the first blacklist set.
[0209] S82: The user sends the SQL entity identifier of the data to be migrated in the Oracle database to the lexical analyzer 702 through the first interface Sp_delete_reserved_keyword().
[0210] Optionally, the user enters the following statement in the script input interface of the data migration system: Sp_delete_reserved_keyword(a1). The SQL entity identifier a1 of the a1 data table in the Oracle database, that is, the reserved word a1 to be deleted, is sent to the lexical analyzer 702 through the first interface Sp_delete_reserved_keyword(a1).
[0211] S83: The lexical analyzer 702 determines whether the reserved word to be deleted is a reserved word in the first reserved word set in the cloud database. If so, S84 is executed, otherwise, S88 is executed.
[0212] like Fig. 9 As shown, the first reserved word set in the cloud database is D0 = {a1, a2, ... an, b1, b2, ... bn, c1, c2, ... cn, d1, d2, ... dn}. The reserved word a1 to be deleted is a reserved word in the original reserved word set of the cloud database. Among them, a1, a2, ... an, b1, b2, ... bn, c1, c2, ... cn, d1, d2, ... dn are different reserved words in the first reserved word set.
[0213] S84: The lexical analyzer 702 determines whether the reserved word to be deleted is in the first blacklist. If so, execute S85, otherwise, execute S88.
[0214] like Fig. 9 As shown, in the embodiment of the present application, That is, a1 does not belong to the blacklist reserved words in the first blacklist set H0.
[0215] S85: The lexical analyzer 702 determines whether the reserved word to be deleted is in the pre-acquired white list table. If so, execute S88, otherwise, execute S86.
[0216] like Fig. 9 As shown, the whitelist set is B = {a2, a3, b1, b2, ... bn, c1, c2, d1, d2}. Among them, 2, a3, b1, b2, ... bn, c1, c2, d1, d2 are different reserved words in the whitelist set. That is, a1 does not belong to the reserved words in the pre-acquired whitelist set B and can be added to the first blacklist set.
[0217] S86: The lexical analyzer 702 adds the reserved words to be deleted to the first blacklist set to obtain a second blacklist set.
[0218] like Fig. 9 As shown, the lexical analyzer 702 adds a1 to the first blacklist set H0, and obtains the second blacklist set H2 as {a1, a4, c3, c4, ... cn}.
[0219] S87: The lexical analyzer 702 deletes the reserved words in the second blacklist set from the first reserved word set of the cloud database to obtain a second reserved word set.
[0220] like Fig. 9 As shown, since the original reserved word set D0 in the cloud database is D0 = {a1, a2, ... an, b1, b2, ... bn, c1, c2, ... cn, d1, d2, ... dn}, a1, a4, c3, c4, ... cn in the second blacklist set H1 are deleted, and the second reserved word set is D1 = {a2, a3, a5, ... an, b1, b2, ... bn, c1, c2, d1, d2, ... dn}.
[0221] S88: The lexical analyzer 702 returns the output instruction to the first interface.
[0222] The output command includes one of a successfully deleted output command, a not a reserved word output command, a deleted output command, and an undeletable output command.
[0223] When the reserved word to be deleted is not a reserved word of the first reserved word set in the second database, the output instruction output by the lexical analyzer 702 through the first interface is a successful deletion output instruction. When the reserved word to be deleted is a reserved word of the first reserved word set in the second database, and the reserved word to be deleted belongs to the reserved words in the first blacklist set, the output instruction output by the lexical analyzer 702 through the first interface is a deleted output instruction. When the reserved word to be deleted is a reserved word of the first reserved word set in the second database, the reserved word to be deleted does not belong to the reserved words in the first blacklist set, and the reserved word to be deleted belongs to the reserved words in the whitelist set, the output instruction output by the lexical analyzer 702 through the first interface is an undeletable output instruction.
[0224] When the reserved word to be deleted is a reserved word in the first reserved word set in the second database, the reserved word to be deleted does not belong to the reserved words in the first blacklist set, and the reserved word to be deleted does not belong to the reserved words in the whitelist set, the output instruction output by the lexical analyzer 702 through the first interface is a deletion success instruction.
[0225] S89: The first interface sends the output instruction to the management interface of the data migration system for display.
[0226] like Fig.10 The figure shows the display content of the data migration system management interface of the interactive tool. Fig.10 (a) in the figure shows the content "Delete successfully" when the output command is a successful delete command. Fig.10 (b) in the figure is the displayed content "deleted warning" when the output instruction is a deleted output instruction. Fig.10 (c) in the figure indicates that the output command is not a reserved word and the output command displays “not a reserved word warning”. Fig.10 (d) in the figure is the displayed content "Unable to delete warning" when the output instruction is an output instruction that cannot be deleted.
[0227] S810: When the management interface of the data migration system shows that the deletion is successful, the user confirms again through the management interface whether the reserved word to be deleted is deleted successfully. If successful, execute S811. Otherwise, execute S86.
[0228] like Fig.11 The figure shows a schematic diagram for reconfirmation. Fig.11 (a) in the figure shows "Deleted successfully" on the management interface. Fig.11 As shown in (b), the user opens the script input box of the data migration system and enters Sp_show_deleted_reserved_keyword() in the script input box. The data migration system obtains a request to display a deleted list through the second interface Sp_show_deleted_reserved_keyword(), obtains the deleted list, and outputs it through the second interface and displays it on the management interface. Fig.11 (c) in FIG. 1 is a deleted list displayed on the management interface, wherein the deleted list includes the reserved word a1 to be deleted.
[0229] S811: The lexical analyzer 702 sends the second reserved word set to the replacer 703.
[0230] like Fig. 9 As shown, the lexical analyzer 702 sends the second reserved word set D1 = {a2, a3, a5, ... an, b1, b2, ... bn, c1, c2, d1, d2, ... dn} to the replacer 703.
[0231] S812: The replacer 703 replaces the reserved word set in the cloud database with the second reserved word set.
[0232] like Fig. 9As shown, the replacer 703 replaces the reserved word set in the cloud database with D1 = {a2, a3, a5, ... an, b1, b2, ... bn, c1, c2, d1, d2, ... dn}.
[0233] S813: The replacer 703 sends a migration instruction to the migrator 704.
[0234] After the replacer 703 completes the replacement, it sends a migration instruction to the migrator 704 .
[0235] S814: The migrator 704 migrates the data to be migrated from the Oracle database to the cloud database.
[0236] The migrator receives the migration instruction and migrates the data to be migrated from the Oracle database to the cloud database. Figure 6 The result shown in (b).
[0237] Additionally, if the interactive tool displays a word that is not a reserved word, has been deleted, or cannot be deleted, it ends.
[0238] If the migration fails again, the above steps S81 to S614 are repeated until the migration succeeds.
[0239] It is worth noting that the above-mentioned interactive tools are only represented by mobile phones as schematic representations, and the interactive tools are not specifically limited in the embodiments of the present application.
[0240] See also Fig.12 , is a schematic diagram of a server structure provided in an embodiment of the present application.
[0241] like Fig.12 As shown, the server 1200 includes a processor 1210 and a memory 1220; wherein the memory 1220 stores computer instructions, and the processor 1210 is used to execute the computer instructions, so that the server 1200 executes the data migration method shown above.
[0242] In some embodiments, the processor 1210 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. A general-purpose processor may be a microprocessor or any conventional processor.
[0243] In some embodiments, the memory 1220 may be a volatile memory or a non-volatile memory, such as a register. Specifically, a volatile memory refers to a memory in which the data stored inside will be lost when the power supply is interrupted. Among them, the volatile memory is mainly a random access memory (RAM), including a static random access memory (SRAM) and a dynamic random access memory (DRAM). A non-volatile memory refers to a memory in which the data stored inside will not be lost even if the power supply is interrupted. Common non-volatile memories include read-only memory (ROM), optical disks, magnetic disks, solid-state hard disks, and various memory cards based on flash memory technology.
[0244] In some embodiments, the memory 1220 has executable code, and the memory 1210 executes the code to achieve data migration of the data to be migrated.
[0245] Communication interface 1230 is used for external communication. For example, communication interface 1230 is used as a first interface for inputting reserved words to be deleted and outputting warnings to the user, such as deleted warnings, not reserved word warnings, etc. Communication interface 1330 can also be used as a second interface for displaying deleted reserved words.
[0246] The bus can be a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of understanding, Fig.12 It is represented by only one thick line, but it does not mean that there is only one bus or one type of bus.
[0247] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device, the computing device is caused to perform the above-mentioned data migration method. The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that a computing device can store or a data storage device such as a data center containing one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc. The computer-readable storage medium includes instructions that instruct the computing device to perform the above-mentioned data migration method.
[0248] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.
[0249] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data migration method, characterized in that: The method comprises: Acquire a reserved word to be deleted, where the reserved word to be deleted is a structured query language SQL entity identifier of the data to be migrated in the first database; When the first reserved word set of the second database includes the reserved word to be deleted, deleting the reserved word to be deleted from the first reserved word set to obtain a second reserved word set; The first reserved word set in the second database is replaced with the second reserved word set, and the data to be migrated is migrated from the first database to the second database after the second reserved word set is replaced.
2. The method according to claim 1, characterized in that: When the first reserved word set of the second database includes the reserved word to be deleted, deleting the reserved word to be deleted from the first reserved word set to obtain the second reserved word set, comprises: Load the first blacklist set; Adding the reserved word to be deleted to the first blacklist set to obtain a second blacklist set; When the first reserved word set of the second database includes the reserved words to be deleted, the reserved words to be deleted in the second blacklist set are deleted from the first reserved word set.
3. The method according to claim 2, characterized in that: The step of adding the to-be-deleted reserved word to the first blacklist set to obtain a second blacklist set includes: When the reserved word to be deleted does not belong to the blacklist reserved words in the first blacklist set, the reserved word to be deleted is added to the first blacklist set to obtain the second blacklist set, and the blacklist reserved word belongs to the original reserved word set in the second database and does not belong to the first reserved word set.
4. The method according to claim 3, characterized in that: When the reserved word to be deleted does not belong to the blacklist reserved words in the first blacklist set, adding the reserved word to be deleted to the first blacklist set to obtain the second blacklist set, comprising: When the reserved word to be deleted does not belong to the reserved words in the first blacklist set, and the reserved word to be deleted does not belong to the reserved words in the preset whitelist set, the reserved word to be deleted is added to the first blacklist set to obtain the second blacklist set, and the reserved words in the whitelist set are reserved words related to the operation of the second database.
5. The method according to claim 4, characterized in that: The reserved words in the whitelist set include a first reserved word and a second reserved word; The first reserved word is a reserved word in an intersection obtained by intersecting a reserved word set of a plurality of databases with a reserved word set of the second database; The second reserved word is a reserved word related to a function of the second database.
6. The method according to claim 3, characterized in that: When the reserved word to be deleted does not belong to the blacklist reserved words in the first blacklist set, adding the reserved word to be deleted to the first blacklist set to obtain the second blacklist set, comprising: When the reserved word to be deleted is a reserved word in the second database and the reserved word to be deleted does not belong to the blacklist reserved words in the first blacklist set, the reserved word to be deleted is added to the first blacklist set to obtain the second blacklist set.
7. The method according to claim 1, characterized in that: When the first reserved word set of the second database includes the reserved word to be deleted, deleting the reserved word to be deleted from the first reserved word set to obtain the second reserved word set, comprises: When the first reserved word set of the second database includes the reserved word to be deleted, determining whether the reserved word to be deleted belongs to a reserved word in a preset white list set; When it is determined that the reserved word to be deleted does not belong to the reserved words in the preset white list set, the reserved word to be deleted is deleted from the first reserved word set to obtain the second reserved word set.
8. The method according to claim 1, characterized in that: The step of obtaining the reserved word to be deleted includes: In response to a user inputting an SQL entity identifier of the data to be migrated in the first database, obtaining the reserved word to be deleted, or, The SQL entity identifier of the data to be migrated in the first database is screened out from the pre-stored data migration exception log to obtain the reserved word to be deleted.
9. The method according to any one of claims 1 to 8, characterized in that: The first database and the second database are heterogeneous databases.
10. A server, characterized in that: including memory and processor; a memory and a processor, the memory being coupled to the processor; The memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 9.