Data processing methods, apparatus and equipment
By finding and backing up the data of specific target data tables in the test database, the problem of time-consuming and costly backup of test environment data in the existing technology is solved, and a more efficient and economical backup process is achieved.
Patent Information
- Application Number
- CN201910931410.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-29
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2039-09-29
AI Technical Summary
The method of backing up test environment data in the prior art is time-consuming and costly.
Instead of backing up the entire test database, find and back up the data of the data table by obtaining the identification of the data table in the test database.
Effectively reduces the time-consuming and cost of the backup process, because only the specific target data table needs to be backed up.
Smart Images

Figure CN112579344B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database processing, and in particular to a data processing method, device and equipment. Background Art
[0002] With the development of science and technology, databases are used more and more widely. In practical applications, data processing programs or scripts are debugged or tested based on the data stored in the database. Therefore, the existing technology backs up the test environment data based on the database to implement the testing of the program or script. However, the existing method of backing up the test environment data is time-consuming and costly. Summary of the invention
[0003] In order to at least overcome the above-mentioned deficiencies in the prior art, one of the objectives of the present invention is to provide a data processing method, device and equipment.
[0004] An embodiment of the present invention provides a data processing method, which is applied to a test database, wherein the test database stores data required for testing, and the method includes:
[0005] Obtain a first identifier; wherein the first identifier is an identifier of a data table in the test database that needs to be backed up;
[0006] According to the first identifier, searching for a first target data table from the test database;
[0007] Determine the column name and type of each column in the first target data table;
[0008] Creating a first backup table for the first target data table according to the column name and type of each column;
[0009] The data in the first target data table is copied to the first backup table.
[0010] In an optional manner, searching the first target data table from the test database according to the first identifier and determining the column name and type of each column in the first target data table includes:
[0011] According to the query statement, a first target data table corresponding to the first identifier is obtained from the system table of the test database, and the column name and type of each column in the first target data table are determined from the system table according to the query statement.
[0012] In an optional manner, before obtaining the first identifier, the method further includes:
[0013] Identify the target programs and / or target scripts that need to be tested;
[0014] According to the target program and / or target script, the data tables that need to be backed up are determined from all the data tables in the test database.
[0015] In an optional manner, the method further includes:
[0016] receiving a first test request;
[0017] According to the first test request, determine the coding verification information corresponding to the first test request from the historical test request resources, and send the coding verification information; wherein the coding verification information of different test requests are pre-coded using different coding vectors respectively;
[0018] receiving a second test request, where the second test request is obtained according to the coding verification information, and the second test request information includes a second identifier;
[0019] Determine whether the second identifier is consistent with the first identifier. If they are consistent, use the data in the first target data table to test the target program and / or target script.
[0020] An embodiment of the present invention provides a data processing method, which is applied to a test database, and the method includes:
[0021] Obtaining a third identifier; wherein the third identifier is an identifier of a data table in the test database that needs to be restored, and the data table in the test database that needs to be restored is a data table that has been used to test the target program and / or target script;
[0022] According to the third identifier, searching for a second target data table from the test database;
[0023] Deleting the data in the second target data table;
[0024] Finding a second backup table corresponding to the second target data table from the test database, wherein the second backup table is created according to the above data processing method;
[0025] The data in the second backup table is copied to the second target data table, wherein the data in the second backup table is obtained according to the above data processing method.
[0026] In an optional manner, copying the data in the second backup table to the second target data table includes:
[0027] Determine whether the table structure of the second backup table is consistent with the table structure of the second target data table;
[0028] When the table structure of the second backup table is consistent with the table structure of the second target data table, copying the data in the second backup table to the second target data table;
[0029] When the table structure of the second backup table is inconsistent with the table structure of the second target data table, adjusting the table structure of the second backup table with reference to the table structure of the second target data table to obtain a current table structure, wherein the current table structure is consistent with the table structure of the second target data table;
[0030] Copying the data in the second backup table to the second target data table according to the format of the current table structure;
[0031] The table structure of the second target data table after data copying is adjusted to obtain an initial table structure, and the initial table structure is consistent with the table structure of the second backup table.
[0032] An embodiment of the present invention provides a data processing device, which is applied to a test database, wherein the test database stores data required for testing, and the device includes:
[0033] A first acquisition unit is used to acquire a first identifier; wherein the first identifier is an identifier of a data table in the test database that needs to be backed up;
[0034] A first search unit, configured to search for a first target data table from the test database according to the first identifier;
[0035] A first determining unit, configured to determine a column name and a type of each column in the first target data table;
[0036] A creating unit, configured to create a first backup table for the first target data table according to the column name and type of each column;
[0037] A backup unit is used to copy the data in the first target data table to the first backup table.
[0038] An embodiment of the present invention provides a data processing device, which is applied to a test database, and the device includes:
[0039] A second acquisition unit is used to acquire a third identifier; wherein the third identifier is an identifier of a data table in the test database that needs to be restored, and the data table in the test database that needs to be restored is a data table that has been used to test the target program and / or target script;
[0040] A second search unit, configured to search for a second target data table from the test database according to the second identifier;
[0041] A deleting unit, used for deleting data in the second target data table;
[0042] A second determining unit, configured to search the test database for a second backup table corresponding to the second target data table, wherein the second backup table is created according to the above-mentioned data processing method;
[0043] The recovery unit is used to copy the data in the second backup table to the second target data table, wherein the data in the second backup table is obtained according to the above-mentioned data processing method.
[0044] An embodiment of the present invention provides a device, including a processor, a memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; and the processor is used to call program instructions in the memory to execute the above-mentioned data processing method.
[0045] An embodiment of the present invention provides a storage medium on which a program is stored. When the program is executed by a processor, the above-mentioned data processing method is implemented.
[0046] The data processing method, device and equipment provided by the embodiment of the present invention can find the first target data table from the test database according to the first identifier, and create a first backup table for the first target data table according to the column name and type of each column in the first target data table, and then copy the data in the first target data table to the first backup table. In this way, when performing program testing, there is no need to back up the entire test database, only the first target data table needs to be backed up, which effectively reduces time consumption. In addition, since the data stored in the test database can be directly used for program testing, after the data in the first target data table is copied to the first backup table, the data in the first target data table can be directly used for program testing, without the need to add another database on the basis of the test database, which effectively reduces costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention 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 creative work.
[0048] Figure 1 The present invention provides a flowchart of a data processing method.
[0049] Figure 2 Another flow chart of a data processing method provided by an embodiment of the present invention.
[0050] Figure 3 A block diagram of functional units of a data processing device provided by an embodiment of the present invention.
[0051] Figure 4 Another functional unit block diagram of a data processing device provided by an embodiment of the present invention.
[0052] Figure 5 A block diagram of a device provided by an embodiment of the present invention.
[0053] icon:
[0054] 20-data processing device; 211-first acquisition unit; 212-first search unit; 213-first determination unit; 214-creation unit; 215-backup unit; 216-data table determination unit to be backed up; 217-test unit; 221-second acquisition unit; 222-second search unit; 223-deletion unit; 224-second determination unit; 225-recovery unit;
[0055] 70-device; 701-processor; 702-memory; 703-bus. DETAILED DESCRIPTION
[0056] The exemplary embodiments disclosed in the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0057] The embodiments of the present invention provide a data processing method, device and equipment to improve the technical problem that the existing method for backing up test environment data is time-consuming and costly.
[0058] The data processing method, device and apparatus provided in the embodiments of the present invention are to solve the above technical problems, and the overall idea is as follows:
[0059] Obtain a first identifier; wherein the first identifier is an identifier of a data table in the test database that needs to be backed up; according to the first identifier, find out a first target data table from the test database; determine the column name and type of each column in the first target data table; according to the column name and type of each column, create a first backup table for the first target data table; copy the data in the first target data table to the first backup table; wherein the test database stores the data required for the test. In this way, when performing program testing, there is no need to back up the entire test database, only the first target data table needs to be backed up, which effectively reduces time consumption. In addition, since the data stored in the test database can be directly used for program testing, after the data in the first target data table is copied to the first backup table, the data in the first target data table can be directly used for program testing, without the need to add another database on the basis of the test database, which effectively reduces costs.
[0060] In order to better understand the above technical scheme, the technical scheme of the present invention is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present invention and the specific features in the embodiments are detailed descriptions of the technical scheme of the present invention, rather than limitations on the technical scheme of the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.
[0061] An embodiment of the present invention provides a data processing method. Figure 1 This is a flow chart of a data processing method provided according to an embodiment of the present invention. The method is applied to a test database, wherein the test database stores data required for testing. Specifically, the data stored in the test database can be directly used for program testing. In this way, there is no need to copy the data in the test database to a new database, which reduces the use of the database and effectively reduces the cost. The method includes the following steps:
[0062] S21, obtaining a first identifier.
[0063] S22: Find a first target data table from a test database according to the first identifier.
[0064] S23, determining the column name and type of each column in the first target data table.
[0065] S24: Create a first backup table for the first target database according to the column name and type of each column.
[0066] S25, copying the data in the first target data table to the first backup table.
[0067] In this embodiment, the test database has data required for testing. It can be understood that the test database can be obtained based on the production environment database, or through a data construction method, or through other methods, which are not limited here.
[0068] Common methods for processing test data are mainly divided into the following two types:
[0069] 1) For the database under the cloud, use the database under the cloud as an original template, copy the database under the cloud by file copying, and then mount it to a new database.
[0070] 2) For the database on the cloud, use the database on the cloud as an original template to copy a new database.
[0071] It can be understood that a new database can be obtained by the above two methods, but for the database under the cloud and the database on the cloud, the original template is mostly the database of the production environment. There are differences between the database of the production environment and the database of the test environment. The new database obtained by the above two methods plays the role of the initial state snapshot of the test environment. Specifically, the new database obtained by the above two methods is a static snapshot and cannot be directly used to run data processing programs and scripts. In other words, it is impossible to perform any operations on the data in the new database. Therefore, each time a program or script is run for testing, the new database (initial state snapshot database) needs to be copied again to obtain a test database. It can be seen that the common method of processing test data requires two databases, one is the initial state snapshot database, and the other is the test database. Since the database is billed according to the number, the common method of processing test data is costly, and the common method of processing test data is to back up and copy the entire database, which is time-consuming.
[0072] In this embodiment, since the test database has the data required for the test, the test database can be directly used for program or script testing without the need to set up an additional initial state snapshot database, which effectively reduces costs. In addition, the backup of the test database based on this embodiment does not back up the entire test database, but backs up the first target data table in the test database according to the first identifier, which can effectively reduce the time consumption of data backup and improve the efficiency of data backup.
[0073] In S21, the first identifier is the identifier of the data table in the test database that needs to be backed up, wherein the identifier may be the table name of the data table, or may be the set ID of the data table in the test database, which is not limited here.
[0074] Specifically, before obtaining the first identifier, the data table that needs to be backed up in the test database is determined by the following method:
[0075] S201, determining a target program and / or target script that needs to be tested;
[0076] S202: Determine data tables that need to be backed up from all data tables in the test database according to the target program and / or target script.
[0077] Through S201-S202, the data tables that need to be backed up can be determined according to the target program and / or target script actually being tested, avoiding the backup of all data tables in the test database. The data tables can be backed up in a targeted manner, thereby improving the backup efficiency and reducing the backup time.
[0078] In this embodiment, the first identifier can be written into a configuration file or into a specified data table, and then the first identifier can be read from the configuration file or the specified data table when the above data processing method is executed. Specifically, when S21 is executed, the first identifier can be read from the configuration file or the specified data table of the test database. By writing the first identifier into the configuration file or into the specified data table, it is possible to avoid inputting the first identifiers into the test database one by one when executing the above data processing method, and the first identifier can be obtained more efficiently and quickly.
[0079] In S21, the number of first identifiers may be one or more, which is not limited here. For the convenience of subsequent description, this embodiment is described with one first identifier. Of course, in the specific implementation, it is not limited to one first identifier.
[0080] In S22, according to the first identifier, a first target data table is searched from the test database, which specifically includes the following contents: according to the query statement, the first target data table corresponding to the first identifier is acquired from the system table of the test database.
[0081] In this embodiment, the system table may be the sys.columns table.
[0082] In S23, the column name and type of each column in the first target data table may be determined from the sys.columns table according to the query statement.
[0083] In this embodiment, S22 and S23 may also be understood as: acquiring all columns of the first target data table corresponding to the first identifier and the column name and type of each column from the system table of the test database.
[0084] In this embodiment, all columns of the first target data table corresponding to the first identifier and the column name and type of each column are obtained from the system table of the test database, which can be understood as: according to the first identifier, a query is performed in the sys.columns table to obtain all columns of the first target data table and the column name and type of each column. In the query result, name is the column name, system_type_id is the column type, and the max_length field represents the length of the column (if the length of the column type can be specified).
[0085] Specifically, the query statement for obtaining all columns of the first target data table corresponding to the first identifier and the column name and type of each column from the system table of the test database may be as follows:
[0086] SELECT name,system_type_id,max_length FROM sys.columns WHERE object_id=OBJECT_ID('table name')
[0087] It can be understood that the above query statement is only an example of this embodiment. In the specific implementation process, other query statements can also be used to query all columns of the first target data table and the column name and type of each column, which is not limited here.
[0088] Through S23, the first target data table that needs to be backed up can be accurately determined. When performing data backup subsequently, only the first target data table needs to be backed up, and there is no need to back up the entire test database, which improves the efficiency of data backup and reduces the time consumption of data backup.
[0089] In S24, creating a first backup table for the first target data table according to the column name and type of each column specifically includes the following contents: constructing a table creation statement according to the set mapping rule; and creating a first backup table for the first target data table according to the table creation statement.
[0090] In S24, the mapping rule is set according to the first identifier of the first target data table and the identifier of the first backup table, wherein there may be multiple mapping rules. In this embodiment, the mapping rule is set as follows: adding the suffix "_Temp" to the first identifier of the first target data table as the identifier of the first backup table. For example, if the first identifier of the first target data table is "table name", then the identifier of the first backup table is "table name_Temp". Further, the table creation statement may be:
[0091] CREATE TABLE [table name_temp] (
[0093] Column name 1 Column 1 type (column length),
[0094] Column name 2 Column 2 type,
[0095] … )
[0097] Through S24, a table creation statement can be constructed according to the set mapping rules, and a first backup table can be created for the first target data table according to the table creation statement. In this way, the first backup table can be accurately created for the first target data table, and there is a set mapping rule between the first identifier of the first target data table and the identifier of the first backup table. When the number of first target data tables is multiple, the accurate correspondence between the first target data table and the first backup table can be guaranteed, thereby improving the accuracy of subsequent data backup and avoiding deviations in data backup.
[0098] It should be understood that the above-mentioned mapping rules are only used as examples and are not intended to limit the present solution. In some cases, a prefix may be added to the first identifier of the first target data table, as long as the first identifier of the first target data table and the identifier of the first backup table are different and have a one-to-one correspondence.
[0099] In S22-S24, the table structure of the first target data table can be identified based on the test database, so as to create an isomorphic first backup table. There is no need to determine the specific table structures of the first target data table and the first backup table in advance, nor is there any need to determine whether the test database is an off-cloud database or an on-cloud database. This improves the efficiency and flexibility of creating backup tables and effectively reduces time costs.
[0100] In S25, copying the data in the first target data table to the first backup table specifically includes: copying the data in the first target data table to the first backup table according to the set mapping rule.
[0101] Please refer to S24. According to the correspondence between the first identifier of the first target data table and the identifier of the first backup table, the data in the first target data table can be copied to the first backup table. In this way, the accuracy of the data copy (backup) can be guaranteed. For example, if the first identifier of the first target data table is A, the data in the first target data table can be copied to the first backup table identified as A_Temp. When copying, the data can be copied according to the column name.
[0102] In S25, in order to avoid the transmission overhead of a large amount of data, a sql script may be used to copy the data in the first target data table to the first backup table. Specifically, the sql script may be:
[0103] INSERT INTO…SELECT…
[0104] Through S25, the data in the first target data table can be copied to the first backup table instead of backing up all the data in the test database, which can effectively reduce the occupation and overhead of IO, disk and other resources, improve the speed and efficiency of backup, and reduce the time consumption of backup.
[0105] In addition, after copying the data in the first target data table to the first backup table, the data processing method may further include the following steps:
[0106] S261, receiving a first test request.
[0107] S262, according to the first test request, determine the coding verification information corresponding to the first test request from the historical test request resources, and send the coding verification information; wherein the coding verification information of different test requests are pre-coded using different coding vectors.
[0108] S263, receiving a second test request, where the second test request is obtained according to the coding verification information, and the second test request information includes a second identifier.
[0109] S264, determine whether the second identifier is consistent with the first identifier. If they are consistent, use the data in the first target data table to test the target program and / or target script. Otherwise, refuse to use the data in the first target data table to test the target program and / or target script.
[0110] In this embodiment, the target program and / or target script is used for program testing. Since the data in the test database can be directly used for testing, the target program and / or target script can be tested directly based on the data in the first target data table without the need to backup an additional database for testing, which effectively reduces the number of databases and thus reduces costs.
[0111] Through S261-S264, the first test request can be verified before the test, and the verification method is implemented through encoded verification information. In this way, under the premise of ensuring reliable verification of the first test request, the transmission efficiency of the first test request, the encoded verification information and the second test request can be improved, so that the test request can be responded to quickly and the efficiency of the test can be improved.
[0112] exist Figure 1 In the data processing method shown, the copy (backup) function is used before the first test run. It can be understood that the above test database also has a data recovery function, which is used before each subsequent test run.
[0113] Specifically, Figure 1The data processing method shown is used in the initial stage of the test database. In the initial stage, there is no backup table in the test database. The data processing method with data recovery function shown below is executed when there is a backup table in the test database.
[0114] An embodiment of the present invention provides a data processing method. Figure 2 This is a flow chart of a data processing method provided according to an embodiment of the present invention. The method is applied to the above-mentioned test database. There is a backup table in the test database. The method includes the following steps:
[0115] S31, obtaining a third identifier.
[0116] S32: According to the third identifier, find out a second target data table from the test database.
[0117] S33, deleting the data in the second target data table.
[0118] S34, searching the test database for a second backup table corresponding to the second target data table.
[0119] S35, copying the data in the second backup table to the second target data table.
[0120] Understandably, Figure 2 The data processing method shown is to recover the data in the second target data table in the test database. In S31, the third identifier is the identifier of the data table that needs to be recovered in the test database. The data table that needs to be recovered in the test database is a data table that has been used to test the target program and / or target script.
[0121] The second backup table is a backup table of the second target data table, the second backup table is created according to the data processing method shown in S21-S25, and the data in the second backup table is obtained according to the data processing method shown in S21-S25. Specifically, the second backup table and the second target data table both exist in the test database, and the test database is executed Figure 2 The data processing method shown has previously completed backing up the data of the second target data table to the second backup table.
[0122] Understandably, in the implementation Figure 2 Before the data processing method shown, the test database can use the data in the second target data table to perform the running test of the target program and / or target script. After the running test is completed, the data in the second target data table may change. In order to restore the test database for subsequent continued use, Figure 2 The data processing method shown is used to restore the data in the second target data table.
[0123] In S32, the implementation principle of searching for the second target data table from the test database according to the third identifier is similar to the implementation principle of S22, so no further explanation is given here.
[0124] In S33, when the data scale in the second data table is large, in order to increase the speed of deleting data in the second target data table and improve the efficiency of data recovery, a target statement can be used to delete the data in the second target data table. In this embodiment, the target statement can be TRUNCATE TABLE [table name of the second target data table].
[0125] In S34, the second backup table corresponding to the second target data table is searched out from the test database, which can be specifically implemented in the following manner: the second backup table is searched out according to the set mapping rule between the third identifier of the second target data table and the identifier of the second backup table. For example, if the third identifier of the second target data table is "B" and the identifier of the second backup table is "Temp_B", it can be determined that the set mapping rule between the third identifier of the second target data table and the identifier of the second backup table is the prefix "Temp_", and further, the second backup table "Temp_B" is searched out according to the second target data table "B".
[0126] In S35, the data in the second backup table is copied to the second target data table, which can be implemented in the following way:
[0127] According to the correspondence between the third identifier of the second target data table and the identifier of the second backup table, the data in the second backup table is copied to the second target data table, so that the accuracy of the data copy (backup) can be guaranteed. Further, in order to avoid the transmission overhead of a large amount of data, a SQL script can be used to copy the data in the second backup table to the second target data table.
[0128] It is understandable that in some test environments, the second target data table may have an auto-increment column after the test is completed. In this case, it is not allowed to specify the value of the auto-increment column for insertion, and it is not possible to directly copy data like the backup function. Therefore, in order to ensure that the data in the second backup table is completely copied to the second target data table to achieve complete recovery of the second target data table, in S35, the data in the second backup table is copied to the second target data table, which can be specifically implemented in the following way:
[0129] S351, determining whether the table structure of the second backup table is consistent with the table structure of the second target data table.
[0130] S352: When the table structure of the second backup table is consistent with the table structure of the second target data table, copy the data in the second backup table to the second target data table.
[0131] S353, when the table structure of the second backup table is inconsistent with the table structure of the second target data table, the table structure of the second backup table is adjusted with reference to the table structure of the second target data table to obtain the current table structure, and the current table structure is consistent with the table structure of the second target data table.
[0132] S354, copying the data in the second backup table to the second target data table according to the format of the current table structure.
[0133] S355, adjusting the table structure of the second target data table after data copying to obtain an initial table structure, which is consistent with the table structure of the second backup table.
[0134] Through S351-S355, when the table structure of the second target data table changes after the test is completed, the table structure of the second backup table can be adjusted with reference to the table structure of the second target data table, and then the backup is performed, so that the data in the second backup table can be completely copied to the second target data table. In addition, after the data in the second backup table is copied to the second target data table, the table structure of the second target data table can also be adjusted to obtain the initial table structure, which can achieve complete recovery of the second target data table, avoid changes in the table structure of the second target data table due to the test, and enable subsequent tests to be performed based on the most original second target data table.
[0135] In this embodiment, the method shown in S351-S355 can be understood as auto-increment column insertion. Specifically, the auto-increment column insertion can be enabled before the data in the second backup table is copied to the second target data table, and the auto-increment column insertion can be disabled after the data in the second backup table is copied to the second target data table.
[0136] In S35, you can use the following script to enable and disable auto-increment column insertion:
[0137] SET IDENTITY_INSERT [original table name] ON
[0138] INSERT INTO [original table name] (column 1 name, column 2 name...) SELECT column 1 name, column 2 name... FROM [backup table name]
[0139] SET IDENTITY_INSERT [original table name] OFF
[0140] Through S31-S35, the specified data table in the test database can be restored instead of the entire database, which can effectively reduce the occupation and overhead of IO, disk and other resources, improve the speed and efficiency of backup, and reduce the time consumption of backup.
[0141] pass Figure 1 and Figure 2 The data processing method shown only requires one test database to realize data backup and recovery, without the need to set up an additional database, which effectively reduces costs. In addition, data backup and recovery are based on the data table specified in the test database, so it can effectively reduce the occupation and overhead of resources such as IO and disk, improve the speed and efficiency of backup, and reduce the time consumption of backup. Furthermore, since the above method can identify the table structure of the specified data table based on the test database, thereby creating an isomorphic backup table, the efficiency of creating the backup table is improved, and the time cost is effectively reduced.
[0142] pass Figure 1 and Figure 2 The data processing method shown can trigger data backup and recovery with one click, thereby improving the convenience of data backup and recovery.
[0143] The embodiment of the present invention provides a data processing device 20. Figure 3 This is a functional unit block diagram of a data processing device 20 provided according to an embodiment of the present invention. The data processing device 20 includes:
[0144] A first acquisition unit 211 is used to acquire a first identifier; wherein the first identifier is an identifier of a data table in the test database that needs to be backed up;
[0145] A first search unit 212, configured to search for a first target data table from the test database according to the first identifier;
[0146] A first determining unit 213, configured to determine the column name and type of each column in the first target data table;
[0147] A creating unit 214, configured to create a first backup table for the first target data table according to the column name and type of each column;
[0148] The backup unit 215 is configured to copy the data in the first target data table to the first backup table.
[0149] In an optional manner, the first searching unit 212 is configured to:
[0150] According to the query statement, a first target data table corresponding to the first identifier is obtained from the system table of the test database, and the column name and type of each column in the first target data table are determined from the system table according to the query statement.
[0151] In an optional manner, the above query statement may be:
[0152] SELECT name, system_type_id, max_length FROM sys.columns WHERE object_id = OBJECT_ID, the system table is the sys.columns table, the column name is name, and the type is system_type_id.
[0153] In an optional manner, the data processing device 20 further includes a to-be-backed-up data table determining unit 216, which is configured to:
[0154] Identify the target programs and / or target scripts that need to be tested;
[0155] According to the target program and / or target script, the data tables that need to be backed up are determined from all the data tables in the test database.
[0156] In an optional manner, the data processing device 20 further includes a testing unit 217, which is used to:
[0157] receiving a first test request;
[0158] According to the first test request, determine the coding verification information corresponding to the first test request from the historical test request resources, and send the coding verification information; wherein the coding verification information of different test requests are pre-coded using different coding vectors respectively;
[0159] receiving a second test request, where the second test request is obtained according to the coding verification information, and the second test request information includes a second identifier;
[0160] Determine whether the second identifier is consistent with the first identifier. If they are consistent, use the data in the first target data table to test the target program and / or target script.
[0161] The embodiment of the present invention provides a data processing device 20. Figure 4 Another functional unit block diagram of a data processing device 20 provided according to an embodiment of the present invention includes:
[0162] The second acquisition unit 221 is used to acquire a third identifier; wherein the third identifier is an identifier of a data table in the test database that needs to be restored, and the data table in the test database that needs to be restored is a data table that has been used to test the target program and / or target script.
[0163] The second searching unit 222 is configured to search for a second target data table from the test database according to the second table name.
[0164] The deleting unit 223 is used to delete the data in the second target data table.
[0165] The second determining unit 224 is used to search the test database for a second backup table corresponding to the second target data table, where the second backup table is created according to the above data processing method.
[0166] The recovery unit 225 is used to copy the data in the second backup table to the second target data table, where the data in the second backup table is obtained according to the above data processing method.
[0167] In an optional manner, the recovery unit 225 is configured to:
[0168] Determine whether the table structure of the second backup table is consistent with the table structure of the second target data table;
[0169] When the table structure of the second backup table is consistent with the table structure of the second target data table, copying the data in the second backup table to the second target data table;
[0170] When the table structure of the second backup table is inconsistent with the table structure of the second target data table, adjusting the table structure of the second backup table with reference to the table structure of the second target data table to obtain a current table structure, wherein the current table structure is consistent with the table structure of the second target data table;
[0171] Copying the data in the second backup table to the second target data table according to the format of the current table structure;
[0172] The table structure of the second target data table after data copying is adjusted to obtain an initial table structure, and the initial table structure is consistent with the table structure of the second backup table.
[0173] The data processing device 20 includes a processor and a memory. The first acquisition unit 211, the first search unit 212, the first determination unit 213, the creation unit 214, the backup unit 215, the to-be-backed-up data table determination unit 216, the test unit 217, the second acquisition unit 221, the second search unit 222, the deletion unit 223, the second determination unit 224 and the recovery unit 225 are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.
[0174] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the time and cost of backing up and restoring the test environment data can be reduced by adjusting the kernel parameters.
[0175] An embodiment of the present invention provides a storage medium on which a program is stored. When the program is executed by a processor, the data processing method is implemented.
[0176] An embodiment of the present invention provides a processor, which is used to run a program, wherein the data processing method is executed when the program is run.
[0177] An embodiment of the present invention provides a device, such as Figure 5 As shown, the device 70 includes at least one processor 701, at least one memory 702 and a bus connected to the processor 701; the processor 701 and the memory 702 communicate with each other through the bus 703; the processor 701 is used to call the program instructions in the memory 702 to execute the above data processing method. The device 70 in this article can be a server, a PC, a PAD, a mobile phone, etc.
[0178] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing the following method steps:
[0179] Obtain a first identifier; wherein the first identifier is an identifier of a data table in the test database that needs to be backed up;
[0180] According to the first identifier, searching for a first target data table from the test database;
[0181] Determine the column name and type of each column in the first target data table;
[0182] Creating a first backup table for the first target data table according to the column name and type of each column;
[0183] The data in the first target data table is copied to the first backup table.
[0184] In an optional manner, searching the first target data table from the test database according to the first identifier and determining the column name and type of each column in the first target data table includes:
[0185] According to the query statement, a first target data table corresponding to the first identifier is obtained from the system table of the test database, and the column name and type of each column in the first target data table are determined from the system table according to the query statement.
[0186] In an optional implementation, the query statement may be:
[0187] SELECT name, system_type_id, max_length FROM sys.columns WHERE object_id = OBJECT_ID, the system table is the sys.columns table, the column name is name, and the type is system_type_id.
[0188] In an optional manner, before obtaining the first identifier, the method further includes:
[0189] Identify the target programs and / or target scripts that need to be tested;
[0190] According to the target program and / or target script, the data tables that need to be backed up are determined from all the data tables in the test database.
[0191] In an optional manner, the method further includes:
[0192] receiving a first test request;
[0193] According to the first test request, determine the coding verification information corresponding to the first test request from the historical test request resources, and send the coding verification information; wherein the coding verification information of different test requests are pre-coded using different coding vectors respectively;
[0194] receiving a second test request, where the second test request is obtained according to the coding verification information, and the second test request information includes a second identifier;
[0195] Determine whether the second identifier is consistent with the first identifier. If they are consistent, use the data in the first target data table to test the target program and / or target script.
[0196] Obtaining a third identifier; wherein the third identifier is an identifier of a data table in the test database that needs to be restored, and the data table in the test database that needs to be restored is a data table that has been used to test the target program and / or target script;
[0197] According to the third identifier, searching for a second target data table from the test database;
[0198] Deleting the data in the second target data table;
[0199] Finding a second backup table corresponding to the second target data table from the test database, wherein the second backup table is created according to the above data processing method;
[0200] The data in the second backup table is copied to the second target data table, wherein the data in the second backup table is obtained according to the above data processing method.
[0201] In an optional manner, copying the data in the second backup table to the second target data table includes:
[0202] Determine whether the table structure of the second backup table is consistent with the table structure of the second target data table;
[0203] When the table structure of the second backup table is consistent with the table structure of the second target data table, copying the data in the second backup table to the second target data table;
[0204] When the table structure of the second backup table is inconsistent with the table structure of the second target data table, adjusting the table structure of the second backup table with reference to the table structure of the second target data table to obtain a current table structure, wherein the current table structure is consistent with the table structure of the second target data table;
[0205] Copying the data in the second backup table to the second target data table according to the format of the current table structure;
[0206] The table structure of the second target data table after data copying is adjusted to obtain an initial table structure, and the initial table structure is consistent with the table structure of the second backup table.
[0207] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0208] In a typical configuration, the device includes one or more processors (CPU), memory and bus. The device may also include input / output interface, network interface and the like.
[0209] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
[0210] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0211] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0212] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0213] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A data processing method, characterized in that: Applied to a test database, the test database stores data required for the test, the method comprising: Obtain a first identifier; wherein the first identifier is an identifier of a data table in the test database that needs to be backed up; According to the first identifier, searching for a first target data table from the test database; Determine the column name and type of each column in the first target data table; Creating a first backup table for the first target data table according to the column name and type of each column; Copying the data in the first target data table to the first backup table; The method further comprises: receiving a first test request; According to the first test request, determine the coding verification information corresponding to the first test request from the historical test request resources, and send the coding verification information; wherein the coding verification information of different test requests are pre-coded using different coding vectors respectively; receiving a second test request, where the second test request is obtained according to the coding verification information, and the second test request includes a second identifier; Determine whether the second identifier is consistent with the first identifier, and if consistent, use the data in the first target data table to test the target program and / or target script; The test database also has a data recovery function, which is used before each subsequent test run; The step of searching the first target data table from the test database according to the first identifier and determining the column name and type of each column in the first target data table includes: According to the query statement, a first target data table corresponding to the first identifier is acquired from the system table of the test database, and a column name and type of each column in the first target data table is determined from the system table according to the query statement; Before obtaining the first identifier, the method further includes: Identify the target programs and / or target scripts that need to be tested; According to the target program and / or target script, the data tables that need to be backed up are determined from all the data tables in the test database.
2. A data processing method, characterized in that: Applied to a test database, the method comprises: Obtaining a third identifier; wherein the third identifier is an identifier of a data table in the test database that needs to be restored, and the data table in the test database that needs to be restored is a data table that has been used to test the target program and / or target script; According to the third identifier, searching for a second target data table from the test database; Deleting the data in the second target data table; Finding a second backup table corresponding to the second target data table from the test database, wherein the second backup table is created by the data processing method according to claim 1; The data in the second backup table is copied to the second target data table, wherein the data in the second backup table is obtained by the data processing method according to claim 1.
3. The data processing method according to claim 2, characterized in that: The step of copying the data in the second backup table to the second target data table includes: Determine whether the table structure of the second backup table is consistent with the table structure of the second target data table; When the table structure of the second backup table is consistent with the table structure of the second target data table, copying the data in the second backup table to the second target data table; When the table structure of the second backup table is inconsistent with the table structure of the second target data table, adjusting the table structure of the second backup table with reference to the table structure of the second target data table to obtain a current table structure, wherein the current table structure is consistent with the table structure of the second target data table; Copying the data in the second backup table to the second target data table according to the format of the current table structure; The table structure of the second target data table after data copying is adjusted to obtain an initial table structure, and the initial table structure is consistent with the table structure of the second backup table.
4. A data processing device, the data processing device being used to implement the data processing method according to claim 1, characterized in that: Applied to a test database, the test database stores data required for the test, and the device comprises: A first acquisition unit is used to acquire a first identifier; wherein the first identifier is an identifier of a data table in the test database that needs to be backed up; A first search unit, configured to search for a first target data table from the test database according to the first identifier; A first determining unit, configured to determine a column name and a type of each column in the first target data table; A creating unit, configured to create a first backup table for the first target data table according to the column name and type of each column; A backup unit is used to copy the data in the first target data table to the first backup table.
5. A data processing device, characterized in that: Applied to a test database, the device comprises: A second acquisition unit is used to acquire a third identifier; wherein the third identifier is an identifier of a data table in the test database that needs to be restored, and the data table in the test database that needs to be restored is a data table that has been used to test the target program and / or target script; A second search unit, configured to search for a second target data table from the test database according to the second identifier; A deleting unit, used for deleting data in the second target data table; A second determining unit, configured to search the test database for a second backup table corresponding to the second target data table, wherein the second backup table is created by the data processing method according to any one of claims 1 to 3; A recovery unit is used to copy the data in the second backup table to the second target data table, wherein the data in the second backup table is obtained by the data processing method according to claim 1.
6. A data transmission device, characterized in that: It comprises a processor, a memory and a bus connected to the processor; wherein the processor and the memory communicate with each other via the bus; and the processor is used to call program instructions in the memory to execute the data processing method described in claim 1 above.
7. A storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, the data processing method described in claim 1 is implemented.
Citation Information
Patent Citations
Data processing method and apparatus, terminal and computer-readable storage medium
CN107463693A
Data table backup method and terminal device
CN108121774A
A data table processing method and system
CN109815233A
Test data generation method and device, computer equipment and readable storage medium
CN109815252A