Character type data detection method and device, equipment and storage medium

By obtaining the character set and encoding parameters of the database, directly converting and detecting the encoding value of character data, it solves the problem of low detection efficiency of character data writing failure in database migration, improves detection efficiency and reduces database resource overhead.

CN118656360APending Publication Date: 2024-09-17CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410779712.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

During the database data migration process, the existing technology is inefficient in detecting character data that fails to be written and places a large load on the target database resources, increasing resource overhead.

Method used

By obtaining the character set and encoding parameters of the source database and the target database, the character data to be detected is directly converted into the encoding value of the target character set, and the conversion failure is detected during the conversion process to determine whether the data can be successfully written to the target database to avoid Actual writes and comparisons improve detection efficiency and reduce dependence on the target database.

Benefits of technology

It achieves the ability to efficiently detect the writing of character data before database data migration, reduces database resource overhead and detection time, improves detection efficiency, and avoids load on the target database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656360A
    Figure CN118656360A
Patent Text Reader

Abstract

The invention discloses a character type data detection method and device, equipment and a storage medium. The invention relates to the technical field of data processing. The method comprises the following steps: acquiring a source character set of a source database, a target character set of a target database and a target coding parameter of the target database; converting the to-be-detected character type data in the source database into a target coded value corresponding to the to-be-detected character type data in the target character set; if the target coding value fails to be converted into the character type data corresponding to the target coding value in the target character set, determining that the character type data to be detected cannot be successfully written into the target database; and obtaining identification information of the corresponding to-be-detected character type data of which the target code value is failed in conversion, and outputting the identification information of the corresponding to-be-detected character type data of which the target code value is failed in conversion. The detection method is high in detection efficiency and effectively reduces database resource overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a character data detection method, device, equipment and storage medium. Background Art

[0002] With the development of Internet technology, banking business is gradually transforming towards digitalization and intelligence, and banking business can be processed through various application systems. The data generated in this process can be stored in the database. As the business develops, it may be necessary to migrate data from one source database to another target database. During the database data migration process, due to the properties of the data to be migrated, it may cause a write failure when writing to the target database, thus affecting the normal development of banking business. Therefore, during the database data migration process, it is very important to detect the data that failed to be written.

[0003] Currently, after writing the data to be migrated into the target database, a test can be performed based on the result after writing, thereby determining the data that failed to be written.

[0004] However, in the above process, the data to be migrated needs to be actually written into the target database before detection can be performed, which has low detection efficiency and will generate a certain load on the target database, increasing database resource overhead. Summary of the invention

[0005] The present application provides a character data detection method, device, equipment and storage medium to solve the technical problems of low detection efficiency and high database resource overhead in the detection method of the related art.

[0006] In a first aspect, the present application provides a character data detection method, comprising:

[0007] Acquire a source character set of a source database, a target character set of a target database, and a target encoding parameter of the target database; wherein the source character set is different from the target character set;

[0008] Convert the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set; wherein the encoding parameter of the target encoding value is the target encoding parameter, and the character set corresponding to the character data to be detected is the source character set;

[0009] If the conversion of the target code value into the character data corresponding to the target code value in the target character set fails, determining that the character data to be detected cannot be successfully written into the target database;

[0010] The identification information of the character data to be detected for which the corresponding target code value conversion fails is obtained, and the identification information of the character data to be detected for which the corresponding target code value conversion fails is output.

[0011] In a second aspect, the present application further provides a character data detection device, the device comprising:

[0012] A first acquisition module is used to acquire a source character set of a source database, a target character set of a target database, and a target encoding parameter of the target database; wherein the source character set is different from the target character set;

[0013] A conversion module, used for converting the character data to be detected in the source database into a target encoding value corresponding to the character data to be detected in the target character set; wherein the encoding parameter of the target encoding value is the target encoding parameter, and the character set corresponding to the character data to be detected is the source character set;

[0014] A first determination module, configured to determine that the character data to be detected cannot be successfully written into the target database if conversion fails when converting the target code value into character data corresponding to the target code value in the target character set;

[0015] The acquisition output module is used to acquire the identification information of the character data to be detected for which the corresponding target code value conversion fails, and output the identification information of the character data to be detected for which the corresponding target code value conversion fails.

[0016] In a third aspect, the present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a character data detection method as described in any one of the present applications is implemented.

[0017] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the character data detection method as described in any one of the present applications.

[0018] In a fifth aspect, the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the character data detection method as described in any one of the present applications.

[0019] The technical solution of the present application includes: obtaining a source character set of a source database, a target character set of a target database, and a target encoding parameter of the target database, wherein the source character set is different from the target character set; converting the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set, wherein the encoding parameter of the target encoding value is the target encoding parameter, and the character set corresponding to the character data to be detected is the source character set; if the conversion fails when converting the target encoding value into the character data corresponding to the target encoding value in the target character set, it is determined that the character data to be detected cannot be successfully written into the target database; obtaining the identification information of the character data to be detected whose corresponding target encoding value conversion fails, and outputting the identification information of the character data to be detected whose corresponding target encoding value conversion fails. It has the following technical effects: on the one hand, it can realize the detection of character data before database data migration, and the detection process involves two conversion processes of the character data to be detected to the target encoding value and the target encoding value to the character data corresponding to the target character set, and both of these conversion processes can be directly converted without the need for an intermediate conversion process, so the required time cost is small and the detection efficiency is high. On the other hand, when the conversion of the target encoding value to the character data corresponding to it in the target character set fails, it can be determined that the character data to be detected cannot be successfully written into the target database without the need to compare with the character data to be detected, further improving the detection efficiency. On the other hand, the entire detection process does not rely on the target database resources, nor does it have any impact on the target database, effectively reducing database resource overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0021] Figure 1 A schematic diagram of an application scenario of the character data detection method provided in an embodiment of the present application;

[0022] Figure 2 A flowchart of a character data detection method provided in an embodiment of the present application;

[0023] Figure 3 A schematic diagram of an output interface in a character data detection method provided in an embodiment of the present application;

[0024] Figure 4 A flowchart of another character data detection method provided in an embodiment of the present application;

[0025] Figure 5 A flowchart of another character data detection method provided in an embodiment of the present application;

[0026] Figure 6 A flowchart of another character data detection method provided in an embodiment of the present application;

[0027] Figure 7 A schematic diagram of a detection interval in another character data detection method provided in an embodiment of the present application;

[0028] Figure 8 Another schematic diagram of a detection interval in another character data detection method provided in an embodiment of the present application;

[0029] Fig. 9 A flowchart of another character data detection method provided in an embodiment of the present application;

[0030] Fig.10 A structural schematic diagram of a character data detection device provided in an embodiment of the present application;

[0031] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only the parts related to the present application, rather than all structures, are shown in the accompanying drawings.

[0033] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. The acquisition, storage, use, processing, etc. of data in the technical solution of this application comply with the relevant provisions of national laws and regulations. It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of the implementation of the technical solution of this application, but it does not mean that the applicant has or will necessarily use the solution.

[0034] Database data migration generally refers to exporting data from a source database and then writing the data into a target database. For example, the source database may be an Oracle database (Oracle database, referred to as Oracle). The target database may be a My Structured Query Language database (MySQL).

[0035] During the database data migration process, the following problems may occur when writing to the target database due to database constraints, heterogeneous compatibility and other conditions or reasons, resulting in write failure. Taking MySQL as the target database, some logs returned by MySQL are as follows: [HY000]

[1366] Incorrect integer value:'XXX' for column'xxx'. This error usually occurs when trying to write an incorrect integer value XXX to the database column xxx;

[22001]

[1406] Data too long for column'xxx'. This error indicates that when trying to write data in the database, the length of the data provided exceeds the maximum length limit of the corresponding column xxx;

[23000]

[1062] Duplicate entry'XXX' for key'xxx.PRIMARY'. This error indicates that when writing data in the database, the primary key data to be written already exists and cannot be added repeatedly. The above MySQL logs are all caused by MySQL table constraints and data constraints. Data can be written successfully after modifying the table model or handling the primary and foreign key conflict data.

[0036] In the actual database data migration process, a problem of "wrong character value" may be encountered. A column of character data cannot be written into MySQL, and the log is such as: [HY000]

[1366] Incorrect string value:'\x**\x**'forcolumn'XXX' (where ** represents numbers and letters). This error occurs when incompatible characters are inserted into MySQL. The reason for this inability to write into MySQL is not due to the library table constraints, but to the character data content itself. In this embodiment, similar errors such as "[HY000]

[1366] Incorrect string value" are defined as "wrong character value" errors. In the database data migration process, if the problem of "wrong character value" occurs, it is impossible to determine the cause of the migration failure by comparing the length, type, and primary and foreign key values ​​of the data with the MySQL database table model settings, which causes confusion and troubleshooting difficulties in the migration process, affecting the efficiency of database data migration.

[0037] Based on the different scales of data to be migrated, the time required for the database data migration process ranges from minutes to days. However, regardless of the length of time for the entire migration process, data write failures need to be repaired or a repair plan determined in the shortest possible time. Otherwise, if some data is not written successfully, the data on the target database will be incomplete, resulting in the inability to operate the business normally. In practice, during the migration process of cutover switching, it may be necessary to stop the operation of the source database to obtain strict data consistency between the source database and the target database. The connection process of migration, switching, and startup is even more compact. Once a problem occurs and needs to be handled, it will affect the success of the entire migration switch. Therefore, during the database data migration process, it is very important to detect the data that causes the "wrong character value" error.

[0038] Figure 1 A schematic diagram of an application scenario of the character data detection method provided in the embodiment of the present application. Figure 1 As shown, the character data detection method provided in this embodiment can be applied to Figure 1 In the electronic device 11 shown. The electronic device 11 in this embodiment can be a computer device, a server, etc. The electronic device 11 in this embodiment can interact with the device 12 where the source database is located to obtain the character data to be detected in the source database, thereby realizing the character data detection method provided in this embodiment. The character data detection method provided in this embodiment can detect in advance before database data migration, thereby improving detection efficiency and reducing database resource overhead.

[0039] The character data detection method of the present application is further described in detail below through several specific embodiments.

[0040] Figure 2 The present invention provides a flowchart of a character data detection method. The method can be performed by a character data detection device, which can be implemented in the form of hardware and / or software, and the character data detection device can be configured in an electronic device. The electronic device here can be Figure 1 For example, the electronic device in this embodiment may be a server. Figure 2 As shown, the character data detection method provided in this embodiment includes the following steps.

[0041] Step 201: Obtain a source character set of a source database, a target character set of a target database, and target encoding parameters of the target database.

[0042] Among them, the source character set is different from the target character set.

[0043] The database data migration process consists of two parts: exporting data from the source database and writing data to the target database. The data types in the database include: numeric type, date type, character type, and large object character type. In Oracle and MySQL, data types such as char and varchar can store character data.

[0044] During the data migration process, character data may cause an "incorrect character value" error. This is because the characters included in the source character set used by the source database are different from the characters included in the target character set used by the target database. That is, a character that exists in the source character set may not exist in the target character set, resulting in an "incorrect character value" error when writing the character to the target database.

[0045] Exemplarily, the source database in this embodiment may be Oracle, and the character set used by it may be the Chinese encoding extension national standard (GBK) character set. The target database in this embodiment may be MySQL, and the character set used by it may be the 8-bit Unicode Transformation Format Multi-Byte 4 (UTF8MB4) character set.

[0046] When character data is stored in a database, it can be stored in a coded value. The coded value here refers to the coded value corresponding to the character data in the character set used by the database. The target coding parameter in this embodiment is used to characterize the parameters of the coded value stored in the target database. Optionally, the coding parameter of the target coding value in this embodiment is used to characterize the base of the target coding value. The target coding parameter can be binary, octal, hexadecimal, etc. Exemplarily, when the target database is MySQL, the target coding parameter is hexadecimal.

[0047] The SQL statement for writing character data into the target database is usually: insert into t_table(col1)values('MySQL data'). Here, t_table represents the table name and col1 represents the column name. For the character data "MySQL data", assuming the target character set is UTF-8, its hexadecimal representation in UTF8 encoding is "4D7953514CE695B0E68DAE". The above SQL statement can be changed to: insert into t_table(col1)values(0x4D7953514CE695B0E68DAE), and the data can still be written and stored and read correctly. When character data is stored in the database, it is written in its original value or the hexadecimal encoding of the character set used by the database, with the same effect.

[0048] The character data stored in the database is a combination of various characters. For the same character data, the encoded values may be different in different character sets. Table 1 shows the hexadecimal encoded values of character data in each character set.

[0049] Table 1 Hexadecimal Encoded Values of Character Data in Each Character Set

[0050]

[0051] It can be seen that the hexadecimal encoded values of some character data may not exist in certain specific character sets, which is determined by the number of characters supported by the specific character set. For example, the hexadecimal encoded value of the character data "巬" does not exist in the Shift_JIS character set. Then, assuming the target character set is Shift_JIS, when writing "巬" into the target database, an "error character value" error will occur, resulting in its failure to be successfully written into the target database. The role of the character data detection method provided in this embodiment is to detect character data such as "巬" that cannot be successfully written into the target database before database data migration. Exemplarily, it is applicable to the detection before data migration from Oracle to MySQL and MySQL-compatible databases to ensure the integrity and availability of the data during the formal migration.

[0052] Optionally, in order to improve efficiency, in step 201, the source character set and the target character set can be obtained through a character set tool. Among them, the character set tool in this embodiment is a tool formed by encapsulating the basic classes java.nio.charset.StandardCharsets and / or sun.nio.cs.ext.ExtendedCharsets. java.nio.charset.StandardCharsets and sun.nio.cs.ext.ExtendedCharsets are basic classes in the JAVA language. This implementation method can quickly obtain the source character set and the target character set. Of course, in this embodiment, the source character set and the target character set can also be obtained by other methods, for example, obtaining the source character set and the target character set from a character set provider.

[0053] Before step 201, the source character set used by the source database and the target character set used by the target database may be determined. In one implementation, character set indication information input by a user may be received, and the source character set and the target character set may be determined according to the character set indication information.

[0054] In a scenario where the target database has multiple character sets and multiple encoding parameters, before step 201, the character data detection method provided in this embodiment also includes the following steps: obtaining each original character set corresponding to the existing character data in the target database and the original encoding parameters corresponding to the existing character data; counting the first occupancy ratio of each original character set and the second occupancy ratio of each original encoding parameter; determining the original character set with the largest corresponding first occupancy ratio as the target character set; and determining the original encoding parameter with the largest corresponding second occupancy ratio as the target encoding parameter.

[0055] When obtaining the original character sets corresponding to the existing character data in the target database and the original encoding parameters corresponding to the existing character data, the original character sets and the original encoding parameters can be determined according to the character set and encoding parameter indication information input by the user. Assuming that there are 5 existing character data, the corresponding original character sets are: character set 1, character set 2, character set 3, character set 1, character set 4, and the corresponding original encoding parameters are: hexadecimal, octal, hexadecimal, hexadecimal and hexadecimal. The first occupancy ratio refers to the ratio of the number of each original character set to the total number of character sets. As shown in the example above, the first occupancy ratio of character set 1 is: 2 / 5, and the first occupancy ratio of character set 2 is: 1 / 5. The second occupancy ratio refers to the ratio of the number of each original encoding parameter to the total number of original encoding parameters. The second occupancy ratio in hexadecimal is: 4 / 5. Afterwards, the original character set with the largest corresponding first occupancy ratio is determined as the target character set, and the original encoding parameter with the largest corresponding second occupancy ratio is determined as the target encoding parameter. This implementation method can determine the most commonly used character set in the target database as the target character set, and determine the most commonly used encoding parameters in the target database as the target encoding parameters, so as to improve the detection value and avoid invalid detection caused by detection based on character sets and encoding parameters that are rarely used in the target database.

[0056] Step 202: Convert the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set.

[0057] Among them, the encoding parameters of the target encoding value are the target encoding parameters, and the character set corresponding to the character data to be detected is the source character set.

[0058] The character data to be detected in this embodiment is the character data in the source database that needs to be migrated to the target database. In this embodiment, the character data to be detected can be determined by a user-specified method or an automatic detection method. The character data to be detected in this embodiment can be data formed during the operation of the application system. Exemplarily, the application system can be a bank transaction system.

[0059] It can be understood that the character set corresponding to the character data to be detected in this embodiment is the source character set, and the encoding parameters of the target encoding value are the target encoding parameters.

[0060] Step 202 can be described as the following expression: StrHex=encode(StrOrigin1,Charset). Wherein, Charset represents the target character set. StrOrigin1 represents the character data to be detected. StrHex represents the target encoding value corresponding to the character data to be detected in the target character set. Exemplarily, StrHex can be in hexadecimal.

[0061] Optionally, in order to improve conversion efficiency, one implementation of step 202 is: convert the character data to be detected into a target encoding value by using an encoding tool. The encoding tool is a tool formed by encapsulating the basic class java.nio.charset.CharsetEncoder. java.nio.charset.CharsetEncoder is a basic class in the JAVA language.

[0062] It should be noted that, as shown in Table 1, some characters do not have corresponding encoding values ​​in some specified character sets. In this embodiment, when a certain character data to be detected does not have a corresponding encoding value in the target character set, this situation can be represented by a preset encoding value. For example, 3F is used to represent this situation. In other words, if the target encoding value of a certain character data to be detected is 3F, it means that the character data to be detected does not have a corresponding encoding value in the target character set.

[0063] It should be noted that, in a scenario where there are multiple character data to be detected, the character data to be detected may be detected one by one or multiple character data to be detected may be detected concurrently in step 202, and this is not limited to the present embodiment.

[0064] Step 203: If the conversion fails when converting the target code value into the character data corresponding to the target code value in the target character set, it is determined that the character data to be detected cannot be successfully written into the target database.

[0065] In this embodiment, after obtaining the target code value, another conversion is required: converting the target code value into the character data corresponding to the target code value in the target character set. The conversion process can be represented by the following expression: StrOrigin2 = decode(StrHex, Charset). Among them, StrOrigin2 represents the character data corresponding to the target code value in the target character set. If the conversion fails, it is determined that the character data to be detected cannot be successfully written into the target database.

[0066] Optionally, in order to improve conversion efficiency, one implementation method of converting the target encoding value into character data corresponding to the target encoding value in the target character set in step 203 is: converting the target encoding value into character data corresponding to the target encoding value in the target character set by using a de-encoding tool. The de-encoding tool is a tool formed by encapsulating the basic class java.nio.charset.CharsetDecoder. java.nio.charset.CharsetDecoder is a basic class in the JAVA language.

[0067] Of course, in this embodiment, the encoding tool, the de-encoding tool and the character set tool can also be obtained by encapsulating the corresponding classes in other programming languages. It should be noted that the character data in this embodiment can also be called a string in a programming language.

[0068] As described in step 202, when a character data to be detected does not have a corresponding code value in the target character set, a preset code value can be used to represent this situation. Then, when converting the preset code value into the character data corresponding to the target code value in the target character set, the conversion will definitely fail, which means that the character data to be detected cannot be successfully written into the target database.

[0069] Furthermore, the character data detection method provided in this embodiment also includes the following steps: if the conversion of the target encoding value into the character data corresponding to the target encoding value in the target character set is successful, it is determined that the character data to be detected can be successfully written into the target database.

[0070] If the target encoding value conversion is successful, it means that the target encoding value is the correct encoding in the target character set, and further indicates that the character data to be detected can be successfully written into the target database; if the target encoding value conversion fails, it means that the target encoding value is not the correct encoding in the target character set, and further indicates that the character data to be detected cannot be successfully written into the target database.

[0071] In this embodiment, whether the conversion of the target encoding value to the character data corresponding to the target encoding value in the target character set fails can be determined in the following manner. In one implementation, determine whether the conversion result includes the character data corresponding to the target encoding value in the target character set. When the conversion result includes the corresponding character data, the conversion is determined to be successful; when the conversion result does not include the corresponding character data, the conversion is determined to be a failure. In another implementation, in a scenario where the conversion is performed using a de-encoding tool, whether the conversion is successful can be determined based on the return result of the de-encoding tool. When the return result of the de-encoding tool is success, the conversion is determined to be successful; when the return result of the de-encoding tool is failure, the conversion is determined to be a failure.

[0072] Step 204: Obtain identification information of the character data to be detected for which the corresponding target code value conversion fails, and output the identification information of the character data to be detected for which the corresponding target code value conversion fails.

[0073] In step 204, identification information of the character data to be detected that fails to convert the corresponding target code value is obtained and output, so as to complete the processing and repair of the data before the database data is officially migrated.

[0074] The identification information in this embodiment is information that can characterize the position of the character data to be detected in the database. Optionally, the identification information in this embodiment is the primary key (PK) of the character data to be detected that fails to convert the corresponding target code value.

[0075] Optionally, in order to facilitate subsequent processing of character data that cannot be successfully written into the target database, the present implementation may further include at least one of the following steps: outputting the character data to be detected for which the corresponding target coding value conversion fails; outputting the target coding value that failed to be converted; outputting the column name corresponding to the character data to be detected for which the corresponding target coding value conversion fails.

[0076] In the character data detection method provided in the present embodiment, detection is performed based on the target encoding value of the character data to be detected. The content of the character data to be detected itself is not important, and there is no need to compare the character data to be detected in the source character set and the character data in the target character set. That is, the detection process has nothing to do with whether the character data to be detected is an uncommon Chinese character, emoticons (emoji, etc.), and various symbols. Even if the data to be detected is an uncommon Chinese character or an emoticon, no additional processing is required. This is a universal and efficient detection method.

[0077] In the detection process of the related technology, it is necessary to write the data exported from the source database into the target database in a single row. The time cost of the continuous writing process to the target database is relatively large, and the overall time increases linearly with the number of data rows. In addition, in normal database data migration, in order to improve the writing performance, batch multi-row and concurrent (parallel) methods are often performed simultaneously. Since it is impossible to locate a specific error row in a batch write when there are multiple rows in batches, the writing performance can only be improved by concurrency to shorten the overall time consumption. Furthermore, the main factor affecting the performance (for example, time consumption) of writing to the target database is still the performance of the target database, which is affected by multiple factors such as the configuration specifications of the target database instance. Overall, the above detection process consumes a lot of time and cannot be well optimized. Moreover, the detection process depends on the target database. Since the data needs to be actually written to the target database, the storage space of the target database needs to be occupied. Moreover, continuous concurrent writing will generate a certain load on the target database. If the target database is an online system, there will be a certain impact. If a second set of standby target databases is used as the database in the detection process, the database resource overhead is increased as a whole.

[0078] Compared with the detection methods in related technologies, the character data detection method provided in this embodiment moves the calculations required for the character data detection process from the target database to external conventional application servers and other electronic devices, and will not generate any load on the target database. Therefore, the entire detection process does not rely on any target database resources and will not have any impact on the target database, effectively reducing overall resource overhead.

[0079] Furthermore, in the detection method provided in the present embodiment, on the one hand, detection is performed using a target character set, and the target character set is the character set of a target database. Therefore, detection can be flexibly implemented for different target databases, and the application scenarios are relatively wide. On the other hand, the detection process involves two conversion processes, namely, the character data to be detected is converted to the target encoding value, and the target encoding value is converted to the corresponding character data in the target character set. Both of these conversion processes can be directly converted without the need for an intermediate conversion process. Therefore, the time cost required is relatively small, and the detection efficiency is relatively high. On another hand, when the conversion fails when converting the target encoding value to the corresponding character data in the target character set, it can be determined that the character data to be detected cannot be successfully written into the target database without the need for comparison with the character data to be detected, which further improves the detection efficiency.

[0080] Figure 3 This is a schematic diagram of an output interface in a character data detection method provided in an embodiment of the present application. Figure 3 As shown, in the output interface 31, the primary key of the character data 1 to be detected whose corresponding target code value conversion fails, the character data 1 to be detected and its corresponding target code value, and the column name of the character data 1 to be detected are output.

[0081] The character data detection method provided in this embodiment includes: obtaining a source character set of a source database, a target character set of a target database, and a target encoding parameter of the target database, wherein the source character set is different from the target character set; converting the character data to be detected in the source database into a target encoding value corresponding to the character data to be detected in the target character set, wherein the encoding parameter of the target encoding value is the target encoding parameter, and the character set corresponding to the character data to be detected is the source character set; if the conversion fails when converting the target encoding value into the character data corresponding to the target encoding value in the target character set, it is determined that the character data to be detected cannot be successfully written into the target database; obtaining the identification information of the character data to be detected whose corresponding target encoding value conversion fails, and outputting the identification information of the character data to be detected whose corresponding target encoding value conversion fails. It has the following technical effects: on the one hand, it can realize the detection of character data before database data migration, and the detection process involves two conversion processes of the character data to be detected to the target encoding value and the target encoding value to the character data corresponding to the target character set, and both of these conversion processes can be directly converted without the need for an intermediate conversion process, so the required time cost is small and the detection efficiency is high. On the other hand, when the conversion of the target encoding value to the character data corresponding to it in the target character set fails, it can be determined that the character data to be detected cannot be successfully written into the target database without the need to compare with the character data to be detected, further improving the detection efficiency. On the other hand, the entire detection process does not rely on the target database resources, nor does it have any impact on the target database, effectively reducing database resource overhead.

[0082] Figure 4 A flowchart of another character data detection method provided in an embodiment of the present application. Figure 2 Based on the illustrated embodiment and various optional implementations, the steps of determining the character data to be detected are described in detail. Figure 4 As shown, the character data detection method provided in this embodiment includes the following steps.

[0083] Step 401: Obtain a source character set of a source database, a target character set of a target database, and target encoding parameters of the target database.

[0084] Among them, the source character set is different from the target character set.

[0085] The implementation process and technical principle of step 401 are similar to those of step 201 and will not be repeated here.

[0086] Step 402: Determine the database table to be migrated.

[0087] In one implementation, the database table to be migrated may be determined according to the indication information of the database table to be migrated input by the user.

[0088] In another implementation manner, all database tables in the source database may be determined as database tables to be migrated.

[0089] In another implementation, in order to improve the migration efficiency and save database resources, step 402 can be implemented as follows: obtain the operation log in the source database; determine the migration value of each database table in the source database according to the operation log, wherein the higher the activity of the data in the database table, the higher the migration value of the database table; determine the database table whose corresponding migration value is greater than the preset migration value threshold as the database table to be migrated. Optionally, when determining the migration value of each database table in the source database according to the operation log, the activity of the data in each database table can be determined according to at least one of the following data included in the operation log: the usage time of the data, the usage frequency of the data, the business corresponding to the data, and the user to whom the data belongs. Determine the migration value of the database table according to the activity of the data in the database table. Among them, the more recent the usage time of the data, the higher its activity; the higher the usage frequency of the data, the higher its activity; the more important the business corresponding to the data, the higher its activity; the higher the user level to which the data belongs, the higher its activity.

[0090] Step 403: Determine at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected.

[0091] The identification information of the character data column to be detected in this embodiment may be the primary key of the database table to be migrated.

[0092] When determining at least one character data column to be detected in the database table to be migrated, it can be implemented in at least the following three implementations.

[0093] In a first implementation, according to the attributes of the data columns in the database table to be migrated, a data column whose corresponding attribute is character data is determined as at least one character data column to be detected.

[0094] The second implementation is to detect whether each column of data in any row of the database table to be migrated is in the character data set according to a preset character data set, and determine the column where the data in the character data set is located as the character data column to be detected.

[0095] A third implementation manner is to determine at least one character data column to be detected according to the indication information input by the user.

[0096] In the scenario where there are multiple database tables to be migrated, the implementation of step 403 is: concurrently determine at least one character data column to be detected in the database table to be migrated and the identification information of the character data column to be detected. That is, in this implementation, the character data detection method provided in this embodiment can be executed with the database table as the concurrent granularity.

[0097] Step 404: Execute the first operation concurrently.

[0098] The first operation includes: for each character data column to be detected, determining each row of character data in the character data column to be detected as the character data to be detected.

[0099] In step 404, for each character data column to be detected in the database table to be migrated, the first operation may be performed concurrently with the data column as the concurrent granularity.

[0100] For example, assuming that the database table to be migrated is table1, and the character data columns to be detected are col1 and col2. Then in step 404, for col1, each line of character data in col1 is determined as the character data to be detected, and for col2, each line of character data in col2 is determined as the character data to be detected, and the above two processes are performed simultaneously.

[0101] It should be noted that, when the number of the character data column to be detected is 1, step 404 is to determine each row of character data in the character data column to be detected as the character data to be detected.

[0102] Step 405: Convert the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set.

[0103] Among them, the encoding parameters of the target encoding value are the target encoding parameters, and the character set corresponding to the character data to be detected is the source character set.

[0104] It can be understood that since in step 404, the data column is used as the concurrent granularity, step 405 can be executed in parallel with the data column as the concurrent granularity to convert the character data to be detected in each character data column to the target encoding value corresponding to the character data to be detected in the target character set.

[0105] Step 406: If the conversion fails when converting the target code value into the character data corresponding to the target code value in the target character set, it is determined that the character data to be detected cannot be successfully written into the target database.

[0106] Step 407: Obtain identification information of the character data to be detected for which the corresponding target code value conversion fails, and output the identification information of the character data to be detected for which the corresponding target code value conversion fails.

[0107] Correspondingly, in step 407, identification information of the character data to be detected for which the corresponding target code value conversion fails can be determined from the identification information of the character data column to be detected.

[0108] The implementation process and technical principle of step 405 and step 202, step 406 and step 203, and step 407 and step 204 are similar, and will not be repeated here.

[0109] It should be noted that when there are multiple character data columns to be detected, the character data to be detected in each character data column to be detected can also be detected in sequence in a serial manner until the character data to be detected in all character data columns to be detected are detected.

[0110] The character data detection method provided in this embodiment concurrently executes a first operation for at least one character data column to be detected in the database table to be migrated: for each character data column to be detected, each row of character data in the character data column to be detected is determined as the character data to be detected, thereby realizing a concurrent detection process with the character data column to be detected as the concurrent granularity, further improving the detection efficiency.

[0111] Figure 5 A flowchart of another character data detection method provided in an embodiment of the present application is shown below. Figure 2 , Figure 4 Based on the illustrated embodiment and various optional implementations, the steps of obtaining the character data to be detected from the source database are described in detail. Figure 5 As shown, the character data detection method provided in this embodiment includes the following steps.

[0112] Step 501: Obtain a source character set of a source database, a target character set of a target database, and target encoding parameters of the target database.

[0113] Among them, the source character set is different from the target character set.

[0114] The implementation process and technical principle of step 501 are similar to those of step 201 and will not be repeated here.

[0115] Step 502: Determine the database table to be migrated.

[0116] The implementation process and technical principle of step 502 are similar to those of step 402 and will not be repeated here.

[0117] Step 503: Determine at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected.

[0118] The implementation process and technical principle of step 503 are similar to those of step 403 and will not be repeated here.

[0119] Optionally, in this embodiment, the identification information of the character data column to be detected is an identification column in the database table to be migrated.

[0120] Step 504: Read at least one character data column and identification column to be detected from the database table to be migrated, and store the at least one character data column and identification column to be detected in a list to be detected.

[0121] The list to be detected includes at least two columns, one of the at least two columns is an identification column, and any one of the at least two columns except the identification column is a character data column to be detected. The list to be detected is located in the memory space.

[0122] In this embodiment, at least one character data column to be detected and an identification column can be stored in a list to be detected, and the list to be detected is located in the memory space of an electronic device that executes the character data detection method provided in this embodiment. Therefore, detection can be implemented in pure memory without relying on external storage space, further improving detection efficiency.

[0123] For example, suppose the database table to be migrated is table1, the character data columns to be detected are col1 and col2, and the identifier column in the database table to be migrated is col0. The list to be detected includes 3 columns, one of which is col1, and the other two are col1 and col2.

[0124] Step 505: Execute the first operation concurrently.

[0125] The first operation includes: for each character data column to be detected in the to-be-detected list, determining each row of character data in the character data column to be detected as the character data to be detected.

[0126] In step 505, for each character data column to be detected in the to-be-detected list, the first operation may be performed concurrently with the data column as the concurrent granularity.

[0127] Step 506: Convert the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set.

[0128] Among them, the encoding parameters of the target encoding value are the target encoding parameters, and the character set corresponding to the character data to be detected is the source character set.

[0129] Step 507: If the conversion fails when converting the target code value into the character data corresponding to the target code value in the target character set, it is determined that the character data to be detected cannot be successfully written into the target database.

[0130] The implementation process and technical principle of step 506 are similar to step 202 and step 405, and step 507 is similar to step 203, which will not be repeated here.

[0131] Step 508: Obtain the identification information of the character data to be detected for which the corresponding target code value conversion fails from the identification column in the list to be detected, and output the identification information of the character data to be detected for which the corresponding target code value conversion fails.

[0132] In step 508, based on the identification column in the to-be-detected list, identification information of the to-be-detected character data for which the corresponding target code value conversion fails can be obtained and output.

[0133] In this embodiment, for general character data, the cost is at the microsecond level, which is an order of magnitude less than the time consumed by directly inserting the data into the target database for trial and error, thereby improving the feasibility of the detection method provided by this embodiment for data volumes of different levels. Moreover, when the length of the character data to be detected increases linearly, due to memory calculation, a greater processor specification expansion benefit can be obtained compared to the detection method of writing to the database.

[0134] The character data detection method provided by the present embodiment can store at least one character data column to be detected and an identification column in a list to be detected, and the list to be detected is located in the memory space of the electronic device that executes the character data detection method provided by the present embodiment. Therefore, the detection can be implemented in pure memory without relying on external storage space, further improving the detection efficiency.

[0135] Figure 6 A flowchart of another character data detection method provided in an embodiment of the present application is shown below. Figure 5 Based on the embodiment shown, it is described how to read at least one character data column to be detected and an identification column based on the data amount of at least one character data column to be detected. Figure 6 As shown, the character data detection method provided in this embodiment includes the following steps.

[0136] Step 601: Obtain a source character set of a source database, a target character set of a target database, and target encoding parameters of the target database.

[0137] Among them, the source character set is different from the target character set.

[0138] The implementation process and technical principle of step 601 are similar to those of step 201 and will not be repeated here.

[0139] Step 602: Determine the database table to be migrated.

[0140] The implementation process and technical principle of step 602 are similar to those of step 402 and will not be repeated here.

[0141] Step 603: Determine at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected.

[0142] The implementation process and technical principle of step 603 are similar to those of step 403 and will not be repeated here.

[0143] Optionally, in this embodiment, the identification information of the character data column to be detected is an identification column in the database table to be migrated.

[0144] Step 604: Obtain the data volume of at least one character data column to be detected.

[0145] In order to avoid the data volume in the character data column to be detected being too large and causing the data volume to overflow the memory space, thereby causing detection errors, in this embodiment, the subsequent detection method can be determined based on the data volume of the character data column to be detected.

[0146] Step 605: If it is determined that the data volume of at least one character data column to be detected is greater than a preset data volume threshold, the at least one character data column to be detected is divided into a plurality of data detection intervals.

[0147] The data volume threshold is a value determined according to the storage volume of the memory space.

[0148] In step 605, a data volume threshold can be determined according to the storage capacity of the memory space. When the data volume of at least one character data column to be detected is greater than the preset data volume threshold, it means that if the data volume of the at least one character data column to be detected is read into the list to be detected at one time, the data volume will be too large and may overflow the memory space, and normal detection cannot be achieved. Therefore, the at least one character data column to be detected is divided into a plurality of data detection intervals.

[0149] When dividing the data detection interval, it can be divided horizontally or vertically, which is not limited in this embodiment.

[0150] Figure 7 A schematic diagram of a detection interval in another character data detection method provided in an embodiment of the present application. Assume that the number of character data columns to be detected is 6 columns. Figure 7The division method shown is a horizontal division method, that is, data columns 1 and 2 are divided into data detection intervals 71, data columns 3 and 4 are divided into data detection intervals 72, and data columns 5 and 6 are divided into data detection intervals 73.

[0151] Figure 8 Another schematic diagram of a detection interval in another character data detection method provided in an embodiment of the present application is provided. Assume that the number of character data columns to be detected is 6, and each column has 100 rows of data. Figure 8 The division method shown is a vertical division method, that is, the 1st to 25th rows of data columns 1 to data columns 6 are divided into data detection intervals 81, the 26th to 50th rows of data columns 1 to data columns 6 are divided into data detection intervals 82, the 51st to 75th rows of data columns 1 to data columns 6 are divided into data detection intervals 83, and the 76th to 100th rows of data columns 1 to data columns 6 are divided into data detection intervals 84.

[0152] Step 606: Read at least one to-be-detected character data column corresponding to the first data detection interval and an identification column corresponding to the first data detection interval.

[0153] In this embodiment, for multiple data detection intervals, the character data to be detected in each data detection interval is detected in turn. At least one character data column to be detected corresponding to the first data detection interval and the identification column corresponding to the first data detection interval are read.

[0154] Step 607: If it is determined that the data volume of at least one character data column to be detected is less than or equal to the data volume threshold, then read at least one character data column to be detected and an identification column.

[0155] Step 608: Store at least one to-be-detected character data column and identification column in a to-be-detected list.

[0156] The list to be detected includes at least two columns, one of the at least two columns is an identification column, and any one of the at least two columns except the identification column is a character data column to be detected. The list to be detected is located in the memory space.

[0157] Step 609: Execute the first operation concurrently.

[0158] The first operation includes: for each character data column to be detected in the to-be-detected list, determining each row of character data in the character data column to be detected as the character data to be detected.

[0159] If what is read is at least one character data column to be detected corresponding to the first data detection interval and an identification column corresponding to the first data detection interval, then correspondingly: in step 608, at least one character data column to be detected corresponding to the first data detection interval and an identification column corresponding to the first data detection interval are stored in a list to be detected; in the first operation in step 609, for each character data column to be detected corresponding to the first data detection interval in the list to be detected, each row of character data in the character data column to be detected is determined as character data to be detected.

[0160] Step 610: Convert the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set.

[0161] Among them, the encoding parameters of the target encoding value are the target encoding parameters, and the character set corresponding to the character data to be detected is the source character set.

[0162] Step 611: If the conversion fails when converting the target code value into the character data corresponding to the target code value in the target character set, it is determined that the character data to be detected cannot be successfully written into the target database.

[0163] The implementation process and technical principle of step 610 are similar to step 202 and step 405, and step 611 is similar to step 203, which will not be repeated here.

[0164] Step 612: Obtain the identification information of the character data to be detected for which the corresponding target code value conversion fails from the identification column in the list to be detected, and output the identification information of the character data to be detected for which the corresponding target code value conversion fails.

[0165] If what is read is at least one character data column to be detected corresponding to the first data detection interval and an identification column corresponding to the first data detection interval, then correspondingly, in step 612, the identification information of the character data to be detected for which the corresponding target coding value conversion fails is obtained from the identification column corresponding to the first data detection interval in the list to be detected, and the identification information of the character data to be detected for which the corresponding target coding value conversion fails is output.

[0166] Step 613: When it is determined that all the character data to be detected in the first data detection interval have been detected, the next data detection interval in the multiple data detection intervals is used as the new first data detection interval, and the process returns to step 606 until all the character data to be detected in the multiple data detection intervals have been detected.

[0167] In step 613, iterative detection of the character data to be detected in the data detection interval is implemented until all the character data to be detected in multiple data detection intervals are detected.

[0168] The character data detection method provided in the present embodiment divides the at least one character data column to be detected into multiple data detection intervals when it is determined that the data amount of at least one character data column to be detected is greater than a preset data amount threshold, and detects the character data to be detected in at least one character data column to be detected corresponding to the multiple data detection intervals in turn, thereby avoiding the problem of reading a large amount of data into the to-be-detected list at one time and overflowing the memory space, making it impossible to perform normal detection, thereby improving the reliability and effectiveness of the detection.

[0169] Fig. 9 A flowchart of another character data detection method provided in an embodiment of the present application. Figure 5 Based on the embodiment shown, it is described how to read at least one character data column to be detected and an identification column based on the data amount of at least one character data column to be detected. Fig. 9 As shown, the character data detection method provided in this embodiment includes the following steps.

[0170] Step 901: Obtain a source character set of a source database, a target character set of a target database, and target encoding parameters of the target database.

[0171] Among them, the source character set is different from the target character set.

[0172] The implementation process and technical principle of step 901 are similar to those of step 201 and will not be repeated here.

[0173] Step 902: Determine the database table to be migrated.

[0174] The implementation process and technical principle of step 902 are similar to those of step 402 and will not be repeated here.

[0175] Step 903: Determine at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected.

[0176] The implementation process and technical principle of step 903 are similar to those of step 403 and will not be repeated here.

[0177] Optionally, in this embodiment, the identification information of the character data column to be detected is an identification column in the database table to be migrated.

[0178] Step 904: Obtain the data volume of at least one character data column to be detected.

[0179] Step 905: If it is determined that the data volume of at least one character data column to be detected is greater than a preset data volume threshold, the at least one character data column to be detected is divided into a plurality of data detection intervals.

[0180] The data volume threshold is a value determined according to the storage volume of the memory space.

[0181] The implementation process and technical principle of step 904 and step 604, and step 905 and step 605 are similar, and will not be repeated here.

[0182] Step 906: Concurrently read at least one to-be-detected character data column corresponding to each data detection interval and an identification column corresponding to the data detection interval.

[0183] This embodiment and Figure 6 The difference between the illustrated embodiments is that, in this embodiment, the data detection interval can be used as the concurrency granularity to concurrently read at least one character data column to be detected corresponding to each data detection interval and the identification column corresponding to the data detection interval, so as to further improve the detection efficiency.

[0184] Step 907: If it is determined that the data volume of at least one character data column to be detected is less than or equal to the data volume threshold, then read at least one character data column to be detected and an identification column.

[0185] Step 908: Store at least one to-be-detected character data column and identification column in a to-be-detected list.

[0186] The list to be detected includes at least two columns, one of the at least two columns is an identification column, and any one of the at least two columns except the identification column is a character data column to be detected. The list to be detected is located in the memory space.

[0187] In this embodiment, if at least one character data column to be detected corresponding to each data detection interval and an identification column corresponding to the data detection interval are read concurrently, then correspondingly, at least one character data column to be detected corresponding to each data detection interval and an identification column corresponding to the data detection interval are also stored in the list to be detected concurrently based on the data detection interval, that is, step 908 is executed concurrently.

[0188] Step 909: Execute the first operation concurrently.

[0189] The first operation includes: for each character data column to be detected in the to-be-detected list, determining each row of character data in the character data column to be detected as the character data to be detected.

[0190] In this embodiment, if at least one character data column to be detected corresponding to each data detection interval and an identification column corresponding to the data detection interval are read concurrently, then correspondingly, step 909 is also executed concurrently with the data detection interval as the granularity. In the first operation in step 909, for each character data column to be detected corresponding to the data detection interval in the list to be detected, each row of character data in the character data column to be detected is determined as the character data to be detected.

[0191] Step 910: Convert the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set.

[0192] Among them, the encoding parameters of the target encoding value are the target encoding parameters, and the character set corresponding to the character data to be detected is the source character set.

[0193] Step 911: If the conversion fails when converting the target code value into the character data corresponding to the target code value in the target character set, it is determined that the character data to be detected cannot be successfully written into the target database.

[0194] The implementation process and technical principle of step 910 and step 202, and step 911 and step 203 are similar, and will not be repeated here.

[0195] Step 912: Obtain the identification information of the character data to be detected for which the corresponding target code value conversion fails from the identification column in the list to be detected, and output the identification information of the character data to be detected for which the corresponding target code value conversion fails.

[0196] In this embodiment, if at least one character data column to be detected corresponding to each data detection interval and the identification column corresponding to the data detection interval are read concurrently, then correspondingly, steps 910, 911 and 912 are also executed concurrently with the data detection interval as the granularity. In step 912, the identification information of the character data to be detected for which the target code value conversion fails is obtained from the identification column corresponding to the data detection interval in the list to be detected, and the identification information of the character data to be detected for which the target code value conversion fails is output.

[0197] The character data detection method provided in the present embodiment, when determining that the data amount of at least one character data column to be detected is greater than a preset data amount threshold, divides at least one character data column to be detected into multiple data detection intervals, and concurrently reads at least one character data column to be detected corresponding to each data detection interval and an identification column corresponding to the data detection interval. On the premise of improving the reliability and effectiveness of the detection, a concurrent detection process with data detection intervals as the granularity is implemented, thereby further improving the detection efficiency.

[0198] Fig.10 This is a schematic diagram of the structure of a character data detection device provided in an embodiment of the present application. Fig.10 As shown, the character data detection device provided in this embodiment includes the following modules: a first acquisition module 1001 , a conversion module 1002 , a first determination module 1003 and an acquisition output module 1004 .

[0199] The first acquisition module 1001 is used to acquire a source character set of a source database, a target character set of a target database, and a target encoding parameter of the target database.

[0200] The source character set is different from the target character set.

[0201] The conversion module 1002 is used to convert the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set.

[0202] Among them, the encoding parameter of the target encoding value is the target encoding parameter, and the character set corresponding to the character data to be detected is the source character set.

[0203] The first determination module 1003 is used to determine that the character data to be detected cannot be successfully written into the target database if the conversion of the target code value into the character data corresponding to the target code value in the target character set fails.

[0204] The acquisition output module 1004 is used to acquire the identification information of the character data to be detected for which the corresponding target code value conversion fails, and output the identification information of the character data to be detected for which the corresponding target code value conversion fails.

[0205] In one embodiment, the device further includes: a second determination module for determining that the character data to be detected can be successfully written into the target database if the conversion of the target code value into the character data corresponding to the target code value in the target character set is successful.

[0206] In one embodiment, the conversion module 1002 is specifically used to: convert the character data to be detected into the target encoding value through an encoding tool. The encoding tool is a tool formed by encapsulating the basic class java.nio.charset.CharsetEncoder. In terms of converting the target encoding value into the character data corresponding to the target encoding value in the target character set, the first determination module 1003 is specifically used to: convert the target encoding value into the character data corresponding to the target encoding value in the target character set through a reverse encoding tool. The reverse encoding tool is a tool formed by encapsulating the basic class java.nio.charset.CharsetDecoder.

[0207] In one embodiment, in the aspect of obtaining the source character set of the source database and the target character set of the target database, the first obtaining module 1001 is specifically used to obtain the source character set and the target character set through a character set tool. The character set tool is a tool formed by encapsulating the basic classes java.nio.charset.StandardCharsets and / or sun.nio.cs.ext.ExtendedCharsets.

[0208] In one embodiment, the device further includes: a second determination module, a third determination module and a concurrent execution module. The second determination module is used to determine the database table to be migrated. The third determination module is used to determine at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected. The concurrent execution module is used to concurrently execute a first operation. Wherein, the first operation includes: for each of the character data columns to be detected, each row of character data in the character data column to be detected is determined as the character data to be detected.

[0209] In one embodiment, the identification information of the character data column to be detected is the identification column in the database table to be migrated. The device also includes a reading and storage module, which is used to read the at least one character data column to be detected and the identification column from the database table to be migrated, and store the at least one character data column to be detected and the identification column in a list to be detected. Wherein, the list to be detected includes at least two columns, one of the at least two columns is the identification column, and any one of the at least two columns except the identification column is the character data column to be detected, and the list to be detected is located in the memory space. The first operation specifically includes: for each of the character data columns to be detected in the list to be detected, each row of character data in the character data column to be detected is determined as the character data to be detected. In terms of obtaining the identification information of the character data to be detected that fails to convert the corresponding target code value, the acquisition output module 1004 is specifically used to: obtain the identification information of the character data to be detected that fails to convert the corresponding target code value from the identification column in the list to be detected.

[0210] In one embodiment, in the aspect of reading the at least one character data column to be detected and the identification column from the database table to be migrated, the reading storage module is specifically used to: obtain the data volume of the at least one character data column to be detected; if it is determined that the data volume of the at least one character data column to be detected is greater than a preset data volume threshold, divide the at least one character data column to be detected into multiple data detection intervals, wherein the data volume threshold is a value determined according to the storage volume of the memory space; read at least one character data column to be detected corresponding to the first data detection interval and the identification column corresponding to the first data detection interval; if it is determined that the data volume of the at least one character data column to be detected is less than or equal to the data volume threshold, read the at least one character data column to be detected and the identification column.

[0211] In one embodiment, the device also includes: a return execution module, which is used to, when it is determined that all the character data to be detected in the first data detection interval have been detected, use the next data detection interval in the multiple data detection intervals as a new first data detection interval, and return to execute the step of "reading at least one character data column to be detected corresponding to the first data detection interval and an identification column corresponding to the first data detection interval" until all the character data to be detected in the multiple data detection intervals have been detected.

[0212] In one embodiment, in the aspect of reading the at least one character data column to be detected and the identification column from the database table to be migrated, the reading storage module is specifically used to: obtain the data volume of the at least one character data column to be detected; if it is determined that the data volume of the at least one character data column to be detected is greater than a preset data volume threshold, divide the at least one character data column to be detected into multiple data detection intervals, wherein the data volume threshold is a value determined according to the storage volume of the memory space; concurrently read at least one character data column to be detected corresponding to each data detection interval and the identification column corresponding to the data detection interval; if it is determined that the data volume of the at least one character data column to be detected is less than or equal to the data volume threshold, read the at least one character data column to be detected and the identification column.

[0213] In one embodiment, there are multiple database tables to be migrated. The third determination module is specifically configured to concurrently determine at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected.

[0214] In one embodiment, in terms of determining at least one character data column to be detected in the database table to be migrated, the third determination module is specifically used to: determine, based on the attributes of the data column in the database table to be migrated, a data column whose corresponding attribute is character data as the at least one character data column to be detected; or, based on a pre-set character data set, detect whether each column of data in any row of the database table to be migrated is located in the character data set, and determine the column where the data located in the character data set is located as the character data column to be detected; or, determine the at least one character data column to be detected based on the indication information input by the user.

[0215] In one embodiment, the second determination module is specifically used to: obtain the operation log in the source database; determine the migration value of each database table in the source database based on the operation log, wherein the higher the activity of the data in the database table, the higher the migration value of the database table; determine the database table whose corresponding migration value is greater than a preset migration value threshold as the database table to be migrated.

[0216] In one embodiment, the device further includes: a second acquisition module, a statistics module, a fourth determination module and a fifth determination module. The second acquisition module is used to acquire each original character set corresponding to the existing character data in the target database and the original encoding parameters corresponding to the existing character data. The statistics module is used to count the first occupancy ratio of each original character set and the second occupancy ratio of each original encoding parameter. The fourth determination module is used to determine the original character set with the largest corresponding first occupancy ratio as the target character set. The fifth determination module is used to determine the original encoding parameter with the largest corresponding second occupancy ratio as the target encoding parameter.

[0217] In one embodiment, the acquisition output module 1004 is also used to: output the character data to be detected for which the corresponding target code value conversion fails; output the target code value that failed to be converted; output the column name corresponding to the character data to be detected for which the corresponding target code value conversion fails.

[0218] In one embodiment, the encoding parameter of the target encoding value is used to characterize the base of the target encoding value, and the identification information is the primary key of the character data to be detected for which the corresponding target encoding value conversion fails.

[0219] The character data detection device provided in the embodiment of the present application can be used to execute the technical solution of the character data detection method in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.

[0220] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the first acquisition module 1001, the conversion module 1002, the first determination module 1003 and the acquisition output module 1004 can be separately established processing elements, or they can be integrated in a chip of the above device for implementation. In addition, they can also be stored in the memory of the above device in the form of program code, and a processing element of the above device can call and execute the functions of the first acquisition module 1001, the conversion module 1002, the first determination module 1003 and the acquisition output module 1004. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in a processor element or an instruction in software form.

[0221] Fig.11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.11 As shown, the electronic device may include: a transceiver 121 , a processor 122 and a memory 123 .

[0222] The processor 122 executes the computer execution instructions stored in the memory, so that the processor 122 executes the scheme in the above embodiment. The processor 122 can be a general-purpose processor, including a central processing unit CPU, a network processor (network processor, NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.

[0223] The memory 123 is connected to the processor 122 via a system bus and completes communication between them. The memory 123 is used to store computer program instructions.

[0224] The transceiver 121 may be used to receive indication information sent by the user equipment, and to obtain character data to be detected.

[0225] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the character data detection device and other computer devices. The memory may include random access memory (RAM) and may also include non-volatile memory.

[0226] An embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the character data detection method in the above embodiment.

[0227] An embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the technical solution of the character data detection method of the above embodiment.

[0228] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the character data detection method provided in any embodiment of the present application.

[0229] In the process of implementation, the computer program product can be written in one or more programming languages ​​or a combination thereof to perform the computer program code of the present application, and the programming language includes an object-oriented programming language, such as Java, Smalltalk, C++, and also includes a conventional procedural programming language, such as "C" language or similar programming language. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).

[0230] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.

Claims

1. A character data detection method, characterized in that: include: Acquire a source character set of a source database, a target character set of a target database, and a target encoding parameter of the target database; wherein the source character set is different from the target character set; Convert the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set; wherein the encoding parameter of the target encoding value is the target encoding parameter, and the character set corresponding to the character data to be detected is the source character set; If the conversion of the target code value into the character data corresponding to the target code value in the target character set fails, determining that the character data to be detected cannot be successfully written into the target database; The identification information of the character data to be detected for which the corresponding target code value conversion fails is obtained, and the identification information of the character data to be detected for which the corresponding target code value conversion fails is output.

2. The method according to claim 1, characterized in that The method further comprises: If the conversion of the target code value into the character data corresponding to the target code value in the target character set is successful, it is determined that the character data to be detected can be successfully written into the target database.

3. The method according to claim 1, characterized in that The step of converting the character data to be detected in the source database into a target encoding value corresponding to the character data to be detected in the target character set includes: The character data to be detected is converted into the target encoding value by using an encoding tool; wherein the encoding tool is a tool formed by encapsulating the basic class java.nio.charset.CharsetEncoder; The step of converting the target code value into character data corresponding to the target code value in the target character set includes: The target encoding value is converted into character data corresponding to the target encoding value in the target character set by a de-encoding tool; wherein the de-encoding tool is a tool formed by encapsulating the basic class java.nio.charset.CharsetDecoder.

4. The method according to claim 3, characterized in that The step of obtaining a source character set of a source database and a target character set of a target database includes: The source character set and the target character set are obtained by using a character set tool, wherein the character set tool is a tool formed by encapsulating the basic classes java.nio.charset.StandardCharsets and / or sun.nio.cs.ext.ExtendedCharsets.

5. The method according to claim 1, characterized in that Before converting the character data to be detected in the source database into the target encoding value corresponding to the character data to be detected in the target character set, the method further includes: Determine the database tables to be migrated; Determine at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected; The first operation is performed concurrently; wherein the first operation includes: for each of the character data columns to be detected, determining each row of character data in the character data column to be detected as the character data to be detected.

6. The method according to claim 5, characterized in that The identification information of the character data column to be detected is an identification column in the database table to be migrated; Before the concurrent execution of the first operation, the method further includes: Reading the at least one character data column to be detected and the identification column from the database table to be migrated, and storing the at least one character data column to be detected and the identification column in a list to be detected; wherein the list to be detected includes at least two columns, one of the at least two columns is the identification column, and any one of the at least two columns except the identification column is the character data column to be detected, and the list to be detected is located in a memory space; For each of the character data columns to be detected, determining each row of character data in the character data column to be detected as the character data to be detected includes: For each of the character data columns to be detected in the to-be-detected list, determining each row of character data in the character data column to be detected as the character data to be detected; The step of obtaining identification information of the character data to be detected for which the corresponding target code value conversion fails includes: From the identification column in the to-be-detected list, identification information of the to-be-detected character data for which the corresponding target code value conversion fails is obtained.

7. The method according to claim 6, characterized in that The step of reading the at least one character data column to be detected and the identification column from the database table to be migrated includes: Acquire the data amount of the at least one character data column to be detected; If it is determined that the data volume of the at least one character data column to be detected is greater than a preset data volume threshold, the at least one character data column to be detected is divided into a plurality of data detection intervals; wherein the data volume threshold is a value determined according to the storage volume of the memory space; Read at least one to-be-detected character data column corresponding to the first data detection interval and an identification column corresponding to the first data detection interval; If it is determined that the data amount of the at least one character data column to be detected is less than or equal to the data amount threshold, the at least one character data column to be detected and the identification column are read.

8. The method according to claim 7, characterized in that The method further comprises: When it is determined that all the character data to be detected in the first data detection interval have been detected, the next data detection interval in the multiple data detection intervals is used as a new first data detection interval, and the process returns to execute the step of "reading at least one character data column to be detected corresponding to the first data detection interval and an identification column corresponding to the first data detection interval" until all the character data to be detected in the multiple data detection intervals have been detected.

9. The method according to claim 6, characterized in that The step of reading the at least one character data column to be detected and the identification column from the database table to be migrated includes: Acquire the data amount of the at least one character data column to be detected; If it is determined that the data volume of the at least one character data column to be detected is greater than a preset data volume threshold, the at least one character data column to be detected is divided into a plurality of data detection intervals; wherein the data volume threshold is a value determined according to the storage volume of the memory space; Concurrently reading at least one to-be-detected character data column corresponding to each of the data detection intervals and an identification column corresponding to the data detection intervals; If it is determined that the data amount of the at least one character data column to be detected is less than or equal to the data amount threshold, the at least one character data column to be detected and the identification column are read.

10. The method according to claim 5, characterized in that There are multiple database tables to be migrated; The step of determining at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected includes: Concurrently determining at least one character data column to be detected in the database table to be migrated and identification information of the character data column to be detected.

11. The method according to claim 5, characterized in that The step of determining at least one character data column to be detected in the database table to be migrated includes: According to the attributes of the data columns in the database table to be migrated, the data columns whose corresponding attributes are character data are determined as the at least one character data column to be detected; or According to a preset character data set, detecting whether each column of data in any row of the database table to be migrated is in the character data set, and determining the column where the data in the character data set is located as the character data column to be detected; or The at least one character data column to be detected is determined according to the indication information input by the user.

12. The method according to claim 5, characterized in that The step of determining the database table to be migrated includes: Obtaining the operation log in the source database; Determine the migration value of each database table in the source database according to the operation log; wherein the higher the activity of the data in the database table, the higher the migration value of the database table; A database table whose corresponding migration value is greater than a preset migration value threshold is determined as the database table to be migrated.

13. The method according to claim 1, characterized in that Before obtaining the target character set of the target database and the target encoding parameters of the target database, the method further includes: Acquire each original character set corresponding to the existing character data in the target database and the original encoding parameters corresponding to the existing character data; Count the first occupancy ratio of each original character set and the second occupancy ratio of each original encoding parameter; Determine the original character set with the largest first occupancy ratio as the target character set; The original coding parameter with the largest corresponding second occupancy ratio is determined as the target coding parameter.

14. The method according to claim 1, characterized in that The method further comprises at least one of the following: Output the character data to be detected that failed to convert the corresponding target encoding value; Output the target encoding value that failed the conversion; Outputs the column name corresponding to the character data to be detected that failed to be converted to the corresponding target encoding value.

15. The method according to claim 1, characterized in that The encoding parameter of the target encoding value is used to characterize the base of the target encoding value, and the identification information is the primary key of the character data to be detected for which the corresponding target encoding value conversion fails.

16. A character data detection device, characterized in that: include: A first acquisition module is used to acquire a source character set of a source database, a target character set of a target database, and a target encoding parameter of the target database; wherein the source character set is different from the target character set; A conversion module, used for converting the character data to be detected in the source database into a target encoding value corresponding to the character data to be detected in the target character set; wherein the encoding parameter of the target encoding value is the target encoding parameter, and the character set corresponding to the character data to be detected is the source character set; A first determination module, configured to determine that the character data to be detected cannot be successfully written into the target database if conversion fails when converting the target code value into character data corresponding to the target code value in the target character set; The acquisition output module is used to acquire the identification information of the character data to be detected for which the corresponding target code value conversion fails, and output the identification information of the character data to be detected for which the corresponding target code value conversion fails.

17. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the character data detection method as claimed in any one of claims 1 to 15 when executing the computer program.

18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the character data detection method as described in any one of claims 1 to 15 is implemented.

19. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the character data detection method according to any one of claims 1 to 15.