CN111090638A - Method and device for comparing transaction functions in database migration - Google Patents
Method and device for comparing transaction functions in database migration Download PDFInfo
- Publication number
- CN111090638A CN111090638A CN201911351967.3A CN201911351967A CN111090638A CN 111090638 A CN111090638 A CN 111090638A CN 201911351967 A CN201911351967 A CN 201911351967A CN 111090638 A CN111090638 A CN 111090638A
- Authority
- CN
- China
- Prior art keywords
- database
- transaction
- result
- comparing
- results
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/214—Database migration support
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2358—Change logging, detection, and notification
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a method and a device for comparing transaction functions in database migration, which comprises the following steps: generating a result query statement according to a table name of a database table in a database and each field name in the database table, wherein the table name is acquired in advance; the database includes: a target database and a source database; acquiring transaction data from a database table, inputting the transaction data into a transaction unit of the database, and acquiring an execution result, wherein the execution result comprises: query results, newly added results, deleted results and updated results; respectively querying an execution result in the target database and the source database by using a result query statement; and comparing the execution result with the transaction function. The method and the device determine whether the migration of the data and the business logic is successful before and after the data migration by executing the transaction units in the databases before and after the migration.
Description
Technical Field
The application belongs to the technical field of database migration, and particularly relates to a method and a device for comparing transaction functions in database migration.
Background
At present, in the fields of finance and communication, foreign databases such as ORACLE and DB2 occupy most markets, but with the development of national information technology industry planning and localization strategy, the localization information products which are autonomous, controllable, safe, reliable and efficiently available are gradually and completely used in various industry organizations. Migration of applications using ORACLE and ORACLE databases to localization databases has become a mainstream trend. In the process of database migration, how to quickly, effectively and automatically check whether the logic execution result (transaction function) of the same transaction in the Oracle database is consistent with the logic execution result (transaction function) in the localization database becomes a big difficulty, and solving the problem is a basic guarantee in the process of database localization substitution. The traditional comparison mode is directed at comparison of the whole database, and the full-volume data comparison is feasible under the condition of small volume of common application data, but is also a heavy-weight comparison, so that the time consumption is high, the consistency of specific transactions is not easy to be accurately compared, and the requirement on fine management in software engineering cannot be met. For the applications of the financial industry and the communication industry, which have the large data volume reaching T magnitude, the traditional mode obviously does not meet the characteristics of the internet industry and the business development requirement.
Disclosure of Invention
The application provides a comparison method of transaction functions in database migration, and the comparison method is used for at least solving the problem that the transaction migration result cannot be transparent and controllable in the database migration process in the prior art.
According to one aspect of the application, a method for comparing transaction functions in database migration is provided, which includes:
generating a result query statement according to a table name of a database table in a database and each field name in the database table, wherein the table name is acquired in advance; the database includes: a target database and a source database;
acquiring transaction data from a database table, inputting the transaction data into a transaction unit of the database, and acquiring an execution result, wherein the execution result comprises: query results, newly added results, deleted results and updated results;
respectively querying an execution result in the target database and the source database by using a result query statement;
and comparing the execution result with the transaction function.
In an embodiment, generating a result query statement according to a table name of a database table in a database and field names in the database table, which are obtained in advance, includes:
and selecting a query reserved word from the query language library, and connecting the query reserved word, the field name and the table name of the database table by using a separator to form a result query statement.
In one embodiment, comparing the execution results with transaction functions includes:
performing stack pressing storage on an execution result;
and comparing the execution results in the stacks to obtain comparison results.
In one embodiment, the step of pushing and saving the execution result includes:
calling out a preset expected value of an execution result and pressing the expected value into an expected value stack;
pressing an execution result in the source database into a source database value stack;
and pushing the execution result of the target database into a target database value stack.
In an embodiment, comparing the execution results in each stack to obtain a comparison result includes:
and comparing whether the values in the expected value stack, the source library value stack and the target library value stack are consistent, if so, the comparison result is successful, otherwise, the comparison result is failed.
According to another aspect of the present application, there is also provided a device for comparing transaction functions in database migration, including:
a result query statement generating unit, configured to generate a result query statement according to a table name of a database table in a database and each field name in the database table, which are acquired in advance; the database includes: a target database and a source database;
the transaction execution unit is used for acquiring transaction data from the database table, inputting the transaction data into a transaction unit of the database, and acquiring an execution result, wherein the execution result comprises: query results, newly added results, deleted results and updated results;
the result query unit is used for respectively querying the execution result in the target database and the source database by using the result query statement;
and the comparison unit is used for comparing the transaction function of the execution result.
In an embodiment, the result query statement generating unit specifically includes:
and the combination module is used for selecting the query reserved words from the query language library and connecting and combining the query reserved words, the field names and the table names of the database table into a result query statement by using separators.
In one embodiment, the alignment unit includes:
the stack pushing and saving module is used for pushing and saving the execution result;
and the stack pushing comparison module is used for comparing the execution results in the stacks to obtain a comparison result.
In one embodiment, the push saving module comprises:
the expected value push module is used for calling out an expected value of a preset execution result and pushing the expected value into an expected value stack;
the source database value stack module is used for pressing the execution result in the source database into a source database value stack;
and the target database value push module is used for pushing the execution result of the target database into the target database value stack.
In an embodiment, the push comparison module specifically includes:
and the value comparison module is used for comparing whether the values in the expected value stack, the source library value stack and the target library value stack are consistent, if so, the comparison result is successful, and otherwise, the comparison result is failed.
According to the method and the device, the execution results of the transaction units in the source database and the target database are verified to verify that the logical relationship between the data is not changed before and after the data migration, so that the problem of comparison of the data transaction function consistency before and after the migration of a single transaction is solved more flexibly, quickly and efficiently.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a comparison method of transaction functions in database migration according to the present application.
Fig. 2 is a flowchart illustrating comparison of transaction functions performed on an execution result in the embodiment of the present application.
Fig. 3 is a flowchart illustrating push saving of an execution result in the embodiment of the present application.
Fig. 4 is a block diagram illustrating a comparison apparatus for transaction functions in database migration according to the present application.
Fig. 5 is a block diagram of a comparison unit in the embodiment of the present application.
Fig. 6 is a block diagram of a push saving module in the embodiment of the present application.
Fig. 7 is a specific implementation of an electronic device in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
At present, in the fields of finance and communication, foreign databases such as ORACLE and DB2 occupy most markets, but with the development of national information technology industry planning and localization strategy, localization information products that are "independently controllable, safe, reliable, and efficiently available" are gradually and fully used in various industry organizations, and therefore, data needs to be migrated from foreign databases such as ORACLE and DB2 to the foreign databases. However, in the process of data migration in the database, a change of the execution logic of the transaction unit (transaction function module) may occur, and the change is not easy to be found, so how to quickly and effectively and automatically check out whether the data in the foreign database and the domestic database of the same transaction and the execution logic sequence are consistent becomes a big difficulty.
Based on the above problem, the present application provides a solution, as shown in fig. 1, to a method for comparing transaction functions in database migration, which specifically includes the following steps:
s101: generating a result query statement according to a table name of a database table in a database and each field name in the database table, wherein the table name is acquired in advance; the database includes: a target database and a source database.
First, a user inputs a name of a transaction unit, a name of a database to be tested, a database table required for a current transaction (function), a precondition of the current transaction, a field to be focused on to obtain an execution result after the current transaction is performed in the transaction unit, and an expected value of the execution result after the current transaction is performed in the transaction unit at an input terminal (such as a PC terminal or a mobile phone terminal). In an embodiment, the name of the database to be tested input by the user may be multiple, and the number of the database tables to be used may also be multiple, and the number is not limited herein. The information input by the user can be stored in formats such as EXCEL or XML, the user only needs to input a specific name of the database, professional database connection pool configuration information is not required to be filled, the application prestores the database connection pool configuration information in a background server in advance, and the background server can automatically adapt to the connection pool of the database as long as the user specifies the specific database.
After the earlier stage work is completed, the background server acquires the table name of the database table from the information input by the user and the field names in the database table to form an SQL query statement for subsequent query.
S102: acquiring transaction data from a database table, inputting the transaction data into a transaction unit of the database, and acquiring an execution result, wherein the execution result comprises: query results, add results, delete results, and update results.
After the step S101 is completed, the transaction unit needs to be verified. The meaning of the transaction units is introduced here, the transaction units are all provided in the database, and the transaction units in the database have independent business logic and the capability of expressing a complete transaction action. Before the transaction unit is checked, the type of a database input by a user is firstly obtained, then a corresponding database driver is configured according to the type of the database to drive the database, and then self-test is carried out to check whether the communication connection between the database and a background server is completely ready.
In a specific embodiment, transaction data that needs to be used is acquired from a database table, the transaction data is input into respective transaction units of a target database and a source database, and the transaction units are executed to obtain transaction results of the target database and the source database, where the executed operations include, but are not limited to: inquiry, addition, deletion and update. After step S102 is executed, the execution results of the transaction units in the target database and the source database may be obtained, where the transaction data input by the transaction units in the target database and the source database are the same, and therefore, under a normal condition, the execution results obtained by the same transaction unit in the target database and the same transaction unit in the source database should be the same.
S103: and inquiring the execution result in the target database and the source database respectively by using the result inquiry statement.
The execution results obtained by executing the transaction units are queried from the target database and the source database respectively by using the result query statement (SQL query statement) obtained in S101.
S104: and comparing the execution result with the transaction function.
After respective execution results of the target database and the source database are inquired, the execution results are compared, so that comparison of transaction functions (transaction units) of the databases is achieved, the fact that the transaction functions in the databases are error-free is guaranteed, and the transaction execution results are still consistent before and after data migration.
The execution main body of the process shown in fig. 1 may be a server, a PC, or a mobile terminal, and the method implements the function of verifying whether the data in the source database and the target database of the same transaction are consistent by operating the transaction units in the database, and also implements the purpose of verifying whether the execution logic sequence of the data is changed before and after the data migration.
In an embodiment, generating a result query statement according to a table name of a database table in a database and field names in the database table, which are obtained in advance, includes:
and selecting a query reserved word from the query language library, and connecting the query reserved word, the field name and the table name of the database table by using a separator to form a result query statement.
In one embodiment, the SQL query is assembled from the database table NAME ACCOUNT and field NAMEs (including NAME of user, id IDENTIFYID, card ACCOUNT number card, AMOUNT of money) entered by the user, and the reserved word is selected from the SQL language library: SELECT and FROM, then concatenate the reserved word, database table name, and field name by "comma" and "_" like spacers to make up the SQL query statement, as follows:
SELECT NAME,IDENTIFYID,CARDID,AMOUNT FROM ACCOUNT;
in one embodiment, as shown in fig. 2, comparing the execution results with transaction functions includes:
s201: and performing stack pressing and saving on the execution result.
And after the transaction unit of each database is executed to obtain an execution result, the execution result is stored. In a specific embodiment, the stack pushing and saving are performed on the execution result, that is, the execution result is pushed to different stacks according to the class.
S202: and comparing the execution results in the stacks to obtain comparison results.
And comparing the execution results (numerical values) stored in each stack according to the rules to obtain comparison results.
In an embodiment, as shown in fig. 3, the pushing and saving the execution result includes:
s301: and calling out the expected value of the preset execution result and pushing the expected value into an expected value stack.
S302: and pushing the execution result in the source database into the value stack of the source database.
S303: and pushing the execution result of the target database into a target database value stack.
In a specific embodiment, the SQL statement is started to query the execution results of the transaction units in the source DataBase and the target DataBase respectively in a JDBC manner (Java DataBase Connectivity, Java DataBase connection), the execution result expected value input by the user in advance is pushed to the "expected value stack", the execution result of the source DataBase is pushed to the "source DataBase value stack", the execution result of the target DataBase is pushed to the "target value stack", and the pushing conditions are as follows:
desired values: jim _22025619601207_2220104236_2347.3, which the expected value user has given, pushes the expected value stack with the transaction name "CheckAccount" after fetching.
Source bank value: the result is queried in the source library through a query statement and is connected through a connector "_", the result of the SQL query is Jim _22025619601207_2220104236_2347.3, and the query result and the transaction name "CheckAccount" are pushed into a "source library value stack".
Target library value: the result of the execution of the query statement in the target library is connected by a connector "_", the result of the SQL query is Jim _22025619601207_2220104236_2347.3, and the query result and the transaction name "CheckAccount" are pushed together to the "target library value stack". And after the stack pushing actions of the three stacks are completed, the query of the execution result of the first transaction unit is completed.
And reading the next transaction unit displayed in the user input information in turn, and executing the processes S201-S202 in turn until the last transaction unit filled in the client input file by the user is executed. And entering a comparison step of the execution results of the transaction unit.
In an embodiment, comparing the execution results in each stack to obtain a comparison result includes:
and comparing whether the values in the expected value stack, the source library value stack and the target library value stack are consistent, if so, the comparison result is successful, otherwise, the comparison result is failed.
In a specific embodiment, the expected value stack, the source library value stack and the target library value stack are traversed respectively, the execution results of the same transaction unit in the three value stacks are compared respectively by taking the transaction unit as an index, if the execution results of the same transaction unit in the three stacks have the same value, the target library metadata and the service logic of the current transaction unit are successfully migrated, and meanwhile, the check result is written back to a comparison result field in a file filled by a user at a client side for the user to check the execution condition of the transaction unit in the current batch.
According to the comparison method, the same transaction unit is executed in different databases to verify whether the data and the service logic before and after the database migration are successfully migrated or not, and the blank of service logic migration result verification in the existing database migration is filled.
Based on the same inventive concept, the embodiment of the present application further provides a comparison apparatus for transaction functions in database migration, which can be used to implement the method described in the foregoing embodiment, as described in the following embodiments. Because the problem solving principle of the device for comparing the transaction functions in the database migration is similar to that of the method for comparing the transaction functions in the database migration, the implementation of the device for comparing the transaction functions in the database migration can be referred to that of the method for comparing the transaction functions in the database migration, and repeated parts are not described again. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. While the system described in the embodiments below is preferably implemented in software, implementations in hardware, or a combination of software and hardware are also possible and contemplated.
As shown in fig. 4, a comparison apparatus for transaction function in database migration provided by the present application includes:
a result query statement generating unit 401, configured to generate a result query statement according to a table name of a database table in a database and each field name in the database table, which are obtained in advance; the database includes: a target database and a source database;
a transaction executing unit 402, configured to obtain transaction data from the database table, input the transaction data into a transaction unit of the database, and obtain an execution result, where the execution result includes: query results, newly added results, deleted results and updated results;
a result query unit 403, configured to query the execution result in the target database and the source database respectively by using the result query statement;
the comparing unit 404 is configured to compare the execution result with the transaction function.
In an embodiment, the result query statement generating unit specifically includes:
and the combination module is used for selecting the query reserved words from the query language library and connecting and combining the query reserved words, the field names and the table names of the database table into a result query statement by using separators.
In one embodiment, as shown in fig. 5, the comparing unit 404 includes:
a push saving module 501, configured to push and save the execution result;
a stack pushing comparison module 502, configured to compare the execution results in each stack to obtain a comparison result.
In one embodiment, as shown in fig. 6, the push saving module 501 includes:
an expected value push module 601, configured to call out an expected value of a preset execution result and push the expected value into an expected value stack;
a source database value push module 602, configured to push an execution result in a source database into a source database value stack;
and a target library value push module 603, configured to push an execution result of the target database into the target library value stack.
In an embodiment, the push comparison module specifically includes:
and the value comparison module is used for comparing whether the values in the expected value stack, the source library value stack and the target library value stack are consistent, if so, the comparison result is successful, and otherwise, the comparison result is failed.
In order to better illustrate the comparison device (hereinafter referred to as device) of transaction function in database migration provided by the present application, a specific embodiment is illustrated herein:
the device supports database consistency comparison of multiple databases, batch execution of multiple transaction units and repeated execution of the transaction units, and is provided with an input end, the text types of the input end are EXCEL and XML, the EXCEL is used in the current case, and meanwhile consistency verification of production non-stop scenes on the transaction units is supported.
The function of checking and inquiring account information of a user is to inquire whether functions are consistent before and after the migration of a transaction unit and whether transaction results are consistent when a database is migrated from Oracle (foreign database) to PostgreSQL (domestic database), and the transaction unit is named as: and inquiring the account number.
The device provides a text template which is convenient for a user to edit for a client, supports two formats of EXCEL and XML, provides configuration for connecting a data source, only needs to fill and write specific database names in a given dictionary without filling professional database connection pool configuration information, selects a designated database in an optional dictionary according to the user, and provides an automatic adaptation data connection pool configuration function. The user fills in the name of the transaction unit, the name of the database to be checked related to the current transaction (usually, this value is set as a default value, multiple options are allowed), the database table associated with the current transaction (multiple tables are supported), the precondition (entry) of the current transaction, the focus field (exit) of the current transaction, and the expected execution result (expected value) of the current transaction according to the template provided by the device.
After the information is filled in, the checking device is started, and the client of the device can be installed on any PC. The device is a packaged Java executable jar package which can run across platforms on a machine with a JRE executable environment installed.
Firstly, the device reads the checked database type, automatically adapts the corresponding database according to a database dictionary table configured by a user, and configures a connection pool; reading a first record CheckAccount to be checked in the input end, and acquiring a target database name: after PostgreSQL, the device will automatically route to the appropriate drive for PostgreSQL according to this name and then establish the database connection. After the step is completed, the device is provided with the condition for communicating with the target database.
The device assembles SQL query sentences required by the execution of the query unit according to the database table names and the field names in the text template filled by the user.
The device reads the database type (PostgreSQL) in the template, adapts to the corresponding database driver, tests whether the database communication is completely ready by the device, and provides a function of testing the connection state.
The name of the transaction unit and the query unit are injected into the device, initialization of the device is completed, connection of a source database and a target database can be obtained simultaneously during initialization, the device starts to execute SQL statements corresponding to the query unit on the source database and the target database respectively in a JDBC mode after initialization is successful, an execution result is pushed after execution is finished, an expected value of a user is pushed into an expected value stack, an execution result of the source database in the execution result of the transaction unit is pushed into a source database value stack, and an execution result of the target database is pushed into a target value stack.
The device takes the next transaction unit input by the user in the input end text template in turn and executes the transaction units in turn until the last transaction unit filled in the client input file by the user is executed, compares whether the execution results in the three stacks are the same or not, if the execution results are the same, the service logic of the transaction unit is still consistent before and after the migration, and if the execution results are different, the service logic of the transaction unit is changed before and after the migration, and the recording and the next processing are required.
The comparison device provided by the application verifies whether the data and the service logic before and after the migration of the database are successfully migrated or not by executing the same transaction unit in different databases, and fills the blank of the verification of the service logic migration result in the current database migration.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principle and the implementation mode of the invention are explained by applying specific embodiments in the invention, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
An embodiment of the present application further provides a specific implementation manner of an electronic device capable of implementing all steps in the method in the foregoing embodiment, and referring to fig. 7, the electronic device specifically includes the following contents:
a processor (processor)701, a memory 702, a communication Interface 703, a bus 704, and a nonvolatile memory 705;
the processor 701, the memory 702 and the communication interface 703 complete mutual communication through the bus 704;
the processor 701 is configured to call the computer programs in the memory 702 and the nonvolatile memory 705, and when the processor executes the computer programs, the processor implements all the steps in the method in the foregoing embodiments, for example, when the processor executes the computer programs, the processor implements the following steps:
s101: generating a result query statement according to a table name of a database table in a database and each field name in the database table, wherein the table name is acquired in advance; the database includes: a target database and a source database.
S102: acquiring transaction data from a database table, inputting the transaction data into a transaction unit of the database, and acquiring an execution result, wherein the execution result comprises: query results, add results, delete results, and update results.
S103: and inquiring the execution result in the target database and the source database respectively by using the result inquiry statement.
S104: and comparing the execution result with the transaction function.
Embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps of the method in the above embodiments, where the computer-readable storage medium stores thereon a computer program, and the computer program when executed by a processor implements all the steps of the method in the above embodiments, for example, the processor implements the following steps when executing the computer program:
s101: generating a result query statement according to a table name of a database table in a database and each field name in the database table, wherein the table name is acquired in advance; the database includes: a target database and a source database.
S102: acquiring transaction data from a database table, inputting the transaction data into a transaction unit of the database, and acquiring an execution result, wherein the execution result comprises: query results, add results, delete results, and update results.
S103: and inquiring the execution result in the target database and the source database respectively by using the result inquiry statement.
S104: and comparing the execution result with the transaction function.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the hardware + program class embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the partial description of the method embodiment. Although embodiments of the present description provide method steps as described in embodiments or flowcharts, more or fewer steps may be included based on conventional or non-inventive means. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an actual apparatus or end product executes, it may execute sequentially or in parallel (e.g., parallel processors or multi-threaded environments, or even distributed data processing environments) according to the method shown in the embodiment or the figures. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, article, or apparatus that comprises the recited elements is not excluded. For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. Of course, in implementing the embodiments of the present description, the functions of each module may be implemented in one or more software and/or hardware, or a module implementing the same function may be implemented by a combination of multiple sub-modules or sub-units, and the like. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form. The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein. The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction. The above description is only an example of the embodiments of the present disclosure, and is not intended to limit the embodiments of the present disclosure. Various modifications and variations to the embodiments described herein will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present specification should be included in the scope of the claims of the embodiments of the present specification.
Claims (12)
1. A method for comparing transaction functions in database migration is characterized by comprising the following steps:
generating a result query statement according to a table name of a database table in a database and each field name in the database table, wherein the table name is acquired in advance; the database includes: a target database and a source database;
acquiring transaction data from the database table, inputting the transaction data into a transaction unit of the database, and acquiring an execution result, wherein the execution result comprises: query results, newly added results, deleted results and updated results;
querying the execution result in the target database and the source database respectively by using the result query statement;
and comparing the execution result with the transaction function.
2. The method for comparing transaction functions according to claim 1, wherein the generating of the result query statement according to the table name of the database table in the database and the field names in the database table obtained in advance comprises:
and selecting a query reserved word from a query language library, and connecting and combining the query reserved word, the field name and the table name of the database table by using separators to form the result query statement.
3. The method for comparing transaction functions according to claim 1, wherein the comparing the execution results with the transaction functions comprises:
performing stack pressing storage on the execution result;
and comparing the execution results in the stacks to obtain comparison results.
4. The method for comparing transaction functions according to claim 3, wherein said pushing and saving the execution result comprises:
calling out a preset expected value of an execution result and pressing the expected value into an expected value stack;
pushing the execution result in the source database into a source database value stack;
and pushing the execution result of the target database into a target database value stack.
5. The method for comparing transaction functions according to claim 4, wherein the comparing the execution results in each stack to obtain a comparison result comprises:
and comparing whether the values in the expected value stack, the source library value stack and the target library value stack are consistent, if so, the comparison result is successful, otherwise, the comparison result is failed.
6. A device for comparing transaction functions in database migration is characterized by comprising:
a result query statement generating unit, configured to generate a result query statement according to a table name of a database table in a database and each field name in the database table, which are acquired in advance; the database includes: a target database and a source database;
a transaction execution unit, configured to obtain transaction data from the database table, input the transaction data into a transaction unit of the database, and obtain an execution result, where the execution result includes: query results, newly added results, deleted results and updated results;
a result query unit, configured to query the execution result in the target database and the source database respectively by using the result query statement;
and the comparison unit is used for comparing the transaction function of the execution result.
7. The apparatus for comparing transaction functions according to claim 6, wherein the result query statement generating unit specifically includes:
and the combination module is used for selecting the query reserved words from the query language library and connecting and combining the query reserved words, the field names and the table names of the database table into the result query statement by using separators.
8. The transaction function comparison device of claim 6, wherein the comparison unit comprises:
the stack pushing and saving module is used for pushing and saving the execution result;
and the stack pushing comparison module is used for comparing the execution results in the stacks to obtain a comparison result.
9. The transaction function comparison device of claim 8, wherein the push saving module comprises:
the expected value push module is used for calling out an expected value of a preset execution result and pushing the expected value into an expected value stack;
a source database value stack module, configured to press the execution result in the source database into a source database value stack;
and the target database value push module is used for pushing the execution result of the target database into a target database value stack.
10. The comparison device of transaction functions of claim 9, wherein the push comparison module specifically comprises:
and the value comparison module is used for comparing whether the values in the expected value stack, the source library value stack and the target library value stack are consistent, if so, the comparison result is successful, and otherwise, the comparison result is failed.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program implements the method of comparing transaction functions of any of claims 1 to 5.
12. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of comparing transaction functions according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911351967.3A CN111090638B (en) | 2019-12-25 | 2019-12-25 | Comparison method and device for transaction functions in database migration |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911351967.3A CN111090638B (en) | 2019-12-25 | 2019-12-25 | Comparison method and device for transaction functions in database migration |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111090638A true CN111090638A (en) | 2020-05-01 |
CN111090638B CN111090638B (en) | 2023-07-04 |
Family
ID=70397095
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911351967.3A Active CN111090638B (en) | 2019-12-25 | 2019-12-25 | Comparison method and device for transaction functions in database migration |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111090638B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111767270A (en) * | 2020-06-28 | 2020-10-13 | 平安普惠企业管理有限公司 | Data migration method, device, server and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2011258002A (en) * | 2010-06-09 | 2011-12-22 | Inforce Co Ltd | Data conversion method, apparatus thereof, and program thereof |
CN103440273A (en) * | 2013-08-06 | 2013-12-11 | 北京航空航天大学 | Data cross-platform migration method and device |
CN106970920A (en) * | 2016-01-14 | 2017-07-21 | 阿里巴巴集团控股有限公司 | A kind of method and apparatus for database data migration |
CN110209650A (en) * | 2019-05-05 | 2019-09-06 | 苏宁易购集团股份有限公司 | The regular moving method of data, device, computer equipment and storage medium |
-
2019
- 2019-12-25 CN CN201911351967.3A patent/CN111090638B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2011258002A (en) * | 2010-06-09 | 2011-12-22 | Inforce Co Ltd | Data conversion method, apparatus thereof, and program thereof |
CN103440273A (en) * | 2013-08-06 | 2013-12-11 | 北京航空航天大学 | Data cross-platform migration method and device |
CN106970920A (en) * | 2016-01-14 | 2017-07-21 | 阿里巴巴集团控股有限公司 | A kind of method and apparatus for database data migration |
CN110209650A (en) * | 2019-05-05 | 2019-09-06 | 苏宁易购集团股份有限公司 | The regular moving method of data, device, computer equipment and storage medium |
Non-Patent Citations (2)
Title |
---|
宋春红;王佳斌;郑力新;: "一种MySQL到HBase的迁移策略的研究与实现" * |
熊军军;: "Informix向Oracle迁移的关键技术研究" * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111767270A (en) * | 2020-06-28 | 2020-10-13 | 平安普惠企业管理有限公司 | Data migration method, device, server and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN111090638B (en) | 2023-07-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8225288B2 (en) | Model-based testing using branches, decisions, and options | |
CA3131079A1 (en) | Test case generation method and device, computer equipment and storage medium | |
WO2016060547A1 (en) | Emulating manual system of filing using electronic document and electronic file | |
CN104133772A (en) | Automatic test data generation method | |
CN110990274B (en) | Data processing method, device and system for generating test cases | |
CN109933521A (en) | Automated testing method, device, computer equipment and storage medium based on BDD | |
CN104794048A (en) | Automatic UI testing method and system | |
US20170060974A1 (en) | Automated conversion tool for facilitating migration between data integration products | |
CN110599341A (en) | Transaction calling method and system | |
CN112699055A (en) | Software automation test method and system with low maintenance cost | |
CN106445815A (en) | Automated testing method and device | |
US20210124752A1 (en) | System for Data Collection, Aggregation, Storage, Verification and Analytics with User Interface | |
CN111367894B (en) | Data comparison method and device based on database migration | |
CN111125067A (en) | Data maintenance method and device | |
CN112631763A (en) | Program changing method and device of host program | |
CN111090638A (en) | Method and device for comparing transaction functions in database migration | |
CN112732367A (en) | Event flow processing method, device and equipment and readable storage medium | |
CN117743145A (en) | Test script generation method and device based on coding template and processing equipment | |
CN110471745A (en) | A kind of service orchestration method and device | |
CN113901025A (en) | Database management method, device, equipment and storage medium | |
CN110968342B (en) | Version comparison method, device and system | |
CN113407378A (en) | Fragmentation information backup method and device for distributed database | |
CN112559331A (en) | Test method and device | |
CN110597862A (en) | Data entry method, equipment and system based on information system | |
KR101737575B1 (en) | Method and device for verifying data based on sql sentences generated automatically |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |