CN113157711A - Database statement execution method and device - Google Patents

Database statement execution method and device Download PDF

Info

Publication number
CN113157711A
CN113157711A CN202110188756.3A CN202110188756A CN113157711A CN 113157711 A CN113157711 A CN 113157711A CN 202110188756 A CN202110188756 A CN 202110188756A CN 113157711 A CN113157711 A CN 113157711A
Authority
CN
China
Prior art keywords
database
execution
changed
statement
executing
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.)
Pending
Application number
CN202110188756.3A
Other languages
Chinese (zh)
Inventor
王鸶楠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN202110188756.3A priority Critical patent/CN113157711A/en
Publication of CN113157711A publication Critical patent/CN113157711A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

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)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database statement execution method and a database statement execution device, wherein the method comprises the following steps: acquiring a database change configuration file, wherein the database change configuration file comprises: database information of a database to be changed and preset database operation executed by the database to be changed; generating a database statement for executing preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation; and executing the database statement for executing the preset database operation on the database to be changed. The invention can simultaneously support the change of various databases without logging in a plurality of machines to realize the change of the databases, thereby greatly improving the database change efficiency.

Description

Database statement execution method and device
Technical Field
The invention relates to the technical field of databases, in particular to a database statement execution method and device.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
In order to solve the problem of performance reduction of a database caused by overlarge data volume, a database is divided into a plurality of databases by using database division tables, an original independent database is divided into a plurality of databases, a large data table is divided into a plurality of small data tables, the data volume of a single database and the data volume of a single data table are reduced, and the purpose of improving the performance of the database is achieved.
In the conventional database change method, a user needs to log in a database client and execute a corresponding database statement (e.g., SQL statement). This approach is only suitable for simple database changes and is not suitable for large systems that employ separate libraries and tables. Therefore, how to provide a database statement execution method suitable for database partitioning and table partitioning is a technical problem to be solved urgently at present.
Disclosure of Invention
The embodiment of the invention provides a database statement execution method, which is used for solving the technical problem that the traditional database change method is not suitable for database change of a database in a branch database and a branch table, and comprises the following steps: acquiring a database change configuration file, wherein the database change configuration file comprises: database information of a database to be changed and preset database operation executed by the database to be changed; generating a database statement for executing preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation; and executing the database statement for executing the preset database operation on the database to be changed.
Optionally, when the preset database operation executed on the database to be changed includes multiple database operations, the database change configuration file further includes: the execution mode and the concurrency number, the execution mode comprises: the method includes performing in series for performing the respective database operations in a serial manner and performing in parallel for performing the respective database operations in a parallel manner.
Optionally, the database statement execution method provided in the embodiment of the present invention further includes: and starting threads with corresponding concurrent number from the thread pool, and executing database statements of each database operation in a parallel mode.
Optionally, the database statement execution method provided in the embodiment of the present invention further includes: monitoring an execution state of executing each database operation on a database to be changed, wherein the execution state comprises the following steps: not started, in execution, successful execution, and failed execution.
Optionally, the database statement execution method provided in the embodiment of the present invention further includes: and when monitoring that the execution of any database operation executed by the database to be changed fails, determining the execution state of the database to be changed as the execution failure.
Optionally, the database statement execution method provided in the embodiment of the present invention further includes: and when the situation that the execution of any one database operation executed by the database to be changed fails is monitored, continuously executing database statements corresponding to other database operations.
Optionally, the database statement execution method provided in the embodiment of the present invention further includes: and when the situation that the execution of any database operation executed by the database to be changed fails is monitored, quitting the thread for executing the corresponding database statement.
Optionally, the database statement execution method provided in the embodiment of the present invention further includes: when monitoring that any one database operation executed by the database to be changed fails to be executed, marking a database statement which fails to be executed;
and under the condition that the database statement which fails to be executed is corrected, re-executing the corrected database statement.
Optionally, the database statement execution method provided in the embodiment of the present invention is a configuration file in a Json format for database change configuration files.
Optionally, in the database statement execution method provided in the embodiment of the present invention, executing a database statement for executing a preset database operation on a database to be changed includes: and calling a JDBC API tool to execute a database statement for executing preset database operation on the database to be changed.
Optionally, in the database statement execution method provided in the embodiment of the present invention, executing a database statement for executing a preset database operation on a database to be changed includes: and calling an SQL Plus tool to execute a database statement for executing preset database operation on the database to be changed.
The embodiment of the invention also provides a database statement execution device, which is used for solving the technical problem that the traditional database change method is not suitable for database change of sub-databases and sub-tables, and comprises the following steps: the configuration file acquisition module is used for acquiring a database change configuration file, wherein the database change configuration file comprises: database information of a database to be changed and preset database operation executed by the database to be changed; the database statement generating module is used for generating a database statement for executing the preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation; and the database statement execution module is used for executing the database statement for executing the preset database operation on the database to be changed.
Optionally, in the database statement execution apparatus provided in the embodiment of the present invention, when the preset database operation executed on the database to be changed includes multiple database operations, the database change configuration file further includes: the execution mode and the concurrency number, the execution mode comprises: the method includes performing in series for performing the respective database operations in a serial manner and performing in parallel for performing the respective database operations in a parallel manner.
Optionally, when the execution manner in the database change configuration file is parallel execution, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module is further configured to: and starting threads with corresponding concurrent number from the thread pool, and executing database statements of each database operation in a parallel mode.
The database statement execution device provided in the embodiment of the present invention further includes: the execution state monitoring module is used for monitoring the execution state of executing each database operation on the database to be changed, wherein the execution state comprises the following steps: not started, in execution, successful execution, and failed execution.
Optionally, in the database statement execution device provided in the embodiment of the present invention, the execution state monitoring module is further configured to: and when monitoring that the execution of any database operation executed by the database to be changed fails, determining the execution state of the database to be changed as the execution failure.
Optionally, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module is further configured to: and when the situation that the execution of any one database operation executed by the database to be changed fails is monitored, continuously executing database statements corresponding to other database operations.
Optionally, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module is further configured to: and when the situation that the execution of any database operation executed by the database to be changed fails is monitored, quitting the thread for executing the corresponding database statement.
Optionally, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module is further configured to: when monitoring that any one database operation executed by the database to be changed fails to be executed, marking a database statement which fails to be executed; and under the condition that the database statement which fails to be executed is corrected, re-executing the corrected database statement.
Optionally, in the database statement execution apparatus provided in the embodiment of the present invention, the database change configuration file is a configuration file in a Json format.
Optionally, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module is further configured to: and calling a JDBC API tool to execute a database statement for executing preset database operation on the database to be changed.
Optionally, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module is further configured to: and calling an SQL Plus tool to execute a database statement for executing preset database operation on the database to be changed.
The embodiment of the invention also provides electronic equipment for solving the technical problem that the traditional database changing method is not suitable for database changing of the sub-database and the sub-table database.
The embodiment of the invention also provides a computer readable storage medium for solving the technical problem that the traditional database change method is not suitable for database change of the sub-database and the sub-table database, and the computer readable storage medium stores a computer program for executing the database statement execution method.
In the embodiment of the invention, the database information of the database to be changed and the preset database operation executed by the database to be changed are configured in the data change configuration file, and then the database statement for executing the preset database operation on the database to be changed is generated according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation, and finally the database statement for executing the preset database operation on the database to be changed is executed, so that the change of the database to be changed is realized. The embodiment of the invention can simultaneously support the change of various types of databases, does not need to log in a plurality of machines to realize the change of the plurality of databases, and greatly improves the database change efficiency.
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. In the drawings:
FIG. 1 is a flow chart of a database statement execution method provided in an embodiment of the present invention;
FIG. 2 is a flow chart of an alternative database statement execution method provided in an embodiment of the present invention;
FIG. 3 is a schematic diagram of a configuration file provided in an embodiment of the present invention;
fig. 4 is a schematic diagram of breakpoint resumption of database operation execution according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating an apparatus for executing database statements according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating an alternative database statement execution apparatus according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a system configuration structure of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
The version iteration of the financial system is very frequent, different versions can be tested in different testing environments, each testing environment is provided with a corresponding database, dozens of database environments are formed by adding environments such as internal, foreign and domestic platforms of a credit card, external output platforms and the like, and the database change is very labor-consuming when dozens of machines are logged in the daily testing process.
Along with the development of services, the number of data tables and the data amount of a single table are larger and larger, in order to improve the performance of the database, the database needs to be divided into a plurality of independent databases, namely, the database with the large data amount is divided into a plurality of data tables, the table with the large data amount is divided into a plurality of data tables, the performance of the single database and the table can achieve the optimal effect, and the performance of the whole database is improved. The credit card divides the database into 6 libraries and 1024 tables because the data volume is very large, and if each data table is changed independently, the workload of database deployment is very large and the repeatability is high.
In order to solve the above problem, an embodiment of the present invention provides a database statement execution method, which may be applied to, but is not limited to, the following types of databases: oracle database, Gauss database, SQLite database.
Fig. 1 is a flowchart of a database statement execution method provided in an embodiment of the present invention, and as shown in fig. 1, the method includes the following steps:
s101, obtaining a database change configuration file, wherein the database change configuration file comprises: database information of the database to be changed and preset database operation executed by the database to be changed.
Optionally, the database statement execution method provided in the embodiment of the present invention is a configuration file in a Json format for database change configuration files.
The database change configuration file obtained in S101 is a file that is configured in advance and includes information of the database to be changed, preset database operations executed on the database to be changed, and the like. The preset database operation executed by the database to be changed may be one database operation or a plurality of database operations.
When the preset database operation executed by the database to be changed comprises a plurality of database operations, the database change configuration file further comprises: the execution mode and the concurrency number, the execution mode comprises: the method includes performing in series for performing the respective database operations in a serial manner and performing in parallel for performing the respective database operations in a parallel manner.
And S102, generating a database statement for executing the preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation.
It should be noted that, in the embodiment of the present invention, the preset database statement is a preset database statement for executing a preset database operation on a certain database, a position corresponding to the database in the preset database statement is represented by a preset symbol, and the preset symbol in the preset database statement is replaced according to the database information of the database to be changed, so that a database statement (i.e., an actually executed database statement) for executing the preset database operation on the database to be changed can be generated.
For example, when the database statement is an SQL statement, the preset symbol "[ X ]" in the SQL statement is replaced, so that the corresponding database operation executed on the database to be changed can be realized. Structured Query Language (SQL), which is a database Query and programming Language for accessing data and querying, updating, and managing relational database systems; SQL statements are one language in which databases are operated.
And S103, executing a database statement for executing preset database operation on the database to be changed.
It should be noted that, after a database statement for executing a preset database operation on the database to be changed is generated, by executing the database statement, the execution of the corresponding preset database operation on the database to be changed can be realized.
In a specific implementation, for the Java version of the database, the S103 may execute a database statement for executing a preset database operation on the database to be changed by calling the JDBC API tool. For the Python version of the database, the above S103 may call the SQL Plus tool to execute a database statement for executing a preset database operation on the database to be changed.
The database statement execution method provided by the embodiment of the invention can be suitable for various database systems with different databases and tables. The sub-base and sub-table comprises two parts of a sub-base and a sub-table, and the production generally comprises the following steps: vertical sorting, horizontal sorting, vertical sorting and horizontal sorting.
The vertical sub-table is formed by splitting the field of a wide table into a plurality of tables according to the access frequency and the principle of whether the field is a large field, so that the service is clear, and partial performance can be improved. After splitting, joint inspection is avoided from a business perspective as much as possible, otherwise performance is not paid. The vertical sub-warehouse is to classify a plurality of tables according to the coupling tightness of the service, and store the tables in different warehouses respectively, and the warehouses can be distributed in different servers, so that the access pressure is loaded by the multiple servers, the performance is greatly improved, the service definition of the whole framework can be improved, and different service warehouses can customize an optimization scheme according to self conditions. It needs to solve all the complex problems brought by cross-library. The horizontal sub-library is used for dividing data of a table (according to data rows) into a plurality of different libraries, each library only has partial data of the table, and the libraries can be distributed in different servers, so that the access pressure is loaded by a plurality of servers, and the performance is greatly improved. It not only needs to solve all the complex problems caused by cross-database, but also needs to solve the data routing problem (introduced after the data routing problem). The horizontal sub-table is used for dividing the data (according to data rows) of one table into a plurality of tables of a plurality of same databases, each table only has partial data of the table, so that the performance can be improved slightly, and the horizontal sub-table is only used as a supplementary optimization of the horizontal sub-table.
Generally, a vertical sub-library and a vertical sub-table scheme are determined according to business coupling tightness in a system design stage, and in the case that the data volume and the access pressure are not particularly large, the schemes of caching, read-write separation, an indexing technology and the like are considered firstly. If the data volume is extremely large and continuously increases, a horizontal database dividing and horizontal table dividing scheme is considered.
As can be seen from the above, in the database statement execution method provided in the embodiment of the present invention, the database information of the database to be changed and the preset database operation executed by the database to be changed are configured in the data change configuration file, and then the database statement for executing the preset database operation on the database to be changed is generated according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation, and finally the database statement for executing the preset database operation on the database to be changed is executed, so as to implement the change of the database to be changed. The embodiment of the invention can simultaneously support the change of various types of databases, does not need to log in a plurality of machines to realize the change of the plurality of databases, and greatly improves the database change efficiency.
In an embodiment, when the preset database operation executed on the database to be changed includes a plurality of database operations, the database statement execution method provided in the embodiment of the present invention further includes: and starting threads with corresponding concurrent number from the thread pool, and executing database statements of each database operation in a parallel mode.
In an embodiment, as shown in fig. 2, the database statement execution method provided in the embodiment of the present invention further includes the following steps:
s104, monitoring the execution state of executing each database operation on the database to be changed, wherein the execution state comprises: not started, in execution, successful execution, and failed execution.
It should be noted that, when it is monitored that any one of the database operations executed by the database to be changed fails to be executed, the database statement execution method provided in the embodiment of the present invention further includes the following steps: and determining the execution state of the database to be changed as the execution failure when the condition that any one database operation executed by the database to be changed is monitored to be failed in execution.
In an embodiment, when it is monitored that any one of database operations executed by a database to be changed fails to be executed, the database statement execution method provided in the embodiment of the present invention may continue to execute database statements corresponding to other database operations.
In an embodiment, when it is monitored that any one of database operations executed on a database to be changed fails to be executed, the database statement execution method provided in the embodiment of the present invention further includes: the thread executing the corresponding database statement is exited.
In an embodiment, when it is monitored that any one of database operations executed on a database to be changed fails to be executed, the database statement execution method provided in the embodiment of the present invention further includes: marking the database statement with failed execution; and under the condition that the database statement which fails to be executed is corrected, re-executing the corrected database statement.
The database statement execution method provided by the embodiment of the invention can meet the requirements of database partitioning and table partitioning and multiple environments, and database execution tools of Java and Python versions can be developed according to the database statement execution method provided by the embodiment of the invention.
The Java version database execution tool comprises the following steps:
the tool analyzes the Json format configuration file and calls JDBC API to execute corresponding database change. The method can be executed in any environment communicated with a network, so that the method can be executed in a local cloud desktop, and the change operation of a plurality of databases can be completed simultaneously without logging in a machine. The tool includes several functions: sub-library and sub-table processing, multi-environment processing, exception processing and other auxiliary functions.
Fig. 3 is a schematic diagram of a configuration file according to an embodiment of the present invention, and as shown in fig. 3, a database change is completed by parsing the configuration file. The configuration file is a json format file, and a plurality of parallel operations are defined by a Groupoperation array. The grouppoperation array may include the following parameters:
1) name represents the Name of the execution of the database;
2) the Description represents the Description executed by the database;
3) executmode indicates an execution mode, namely Concurrentparallel and Sequence serial;
4) concurrence represents the concurrency number, if the execution mode is parallel, the tool can establish a thread pool corresponding to the concurrency number, traverse the whole Operation array and call the thread to execute;
5) operation represents an Operation array, and defines specific database execution Operation. The array contains the following parameters:
name: an operation name;
description: an operation description;
DBURL: JDBC connection strings;
UserName: a database user name;
passage: a database password;
usage: the operation types comprise oracle database operation, SQLite database operation and gauss database operation, and different database drivers can be loaded through the parameters, so that different database links are established;
timeout: the timeout time for the database to execute a single statement;
separator: the database statement separator is used by the tool for analyzing a plurality of SQL statements;
operation option: the optional types of the database operation comprise defaults, only a DROP table does not build the table, if the table exists, the table is deleted and then built, if the table exists, the table is skipped, data in the table is emptied, and only the table is created. The parameter can be configured according to actual conditions, for example, if the table structure of a database is refreshed, some database tables may exist in the current database, but the table structure is not new, the operation of 'deleting the table first and then building the table if the table exists' can be used, and the problem that when the table with the same name exists, the table building can report errors is avoided;
BasketNumberRange: if the basket number is a database table of the sub-database and sub-table, replacing the table name according to the basket number, and establishing a database table corresponding to the basket number;
FailAction: the exception handling mode comprises three fault-tolerant mechanisms of exception continuation, exception exit and breakpoint continuous transmission;
especs: array type, configuring a series of SQL files to be executed.
It should be noted that the grouppoperation defines the content that needs to be executed in the database change (for example, perform a database change operation on an authorized database), and may define a plurality of grouppoperations, and the tool will cyclically service each grouppoperation in the json array to perform a serial operation. The GroupOperation includes information of the operation name, the execution mode, the definition of a group of operations and the like of the operation, the operation in the GroupOperation can be executed serially or in parallel, and the execution mode and the Concurrence number of the operation can be defined through an ExecuteMode parameter and a Concurrence parameter. The tool starts a corresponding number of threads from the thread pool to execute according to the number of concurrencies. Through concurrent operation, database change can be simultaneously operated in a plurality of databases, so that the change efficiency is improved.
It should be noted that the execution mode of the operation is defined by an execute mode parameter, and there are two modes, serial and parallel. One set of operations refers to the value corresponding to the operation array, for example, if the database change is to add a table structure to the authorization database, the authorization database is composed of 6 databases, because the operations of 6 databases need to be configured in the operation array.
BasketNumber defines the basket number of the sub-database sub-table, and the tool can acquire the statement marked by [ X ] in the SQL statement and replace the [ X ] with the basket number to generate a new SQL statement for execution. In the actual database change process, there may be various situations, such as various requirements for refreshing the entire database structure, building only an index, and the like, different operation types may be defined in the OperationOption, including multiple operation definitions such as DROP (delete table), DROP (delete if any when building a table), and skip if any when building a table, and the tool may process the obtained SQL statement, thereby completing different operations.
In an embodiment of the present invention, the SQL statement containing the [ X ] flag is predefined.
For example, a CREATE TABLE TEST _ [ X ] is defined in the SQL statement, and the tool resolves to have the [ X ] flag here, and then replaces this flag in turn according to the values defined in the BasketNumberRange basket number range, executing the statement once each time the replacement is completed, and then replacing the next value until the end. For example, BasketNumberRange is defined as 000001-.
The tool can track the execution state of each Operation in real time, and the Operation state is divided into non-start, execution, successful execution and execution failure, if one SQL file is not successfully executed, the current Operation result is failure, and further the Operation result of the whole group Operation is defined as failure. The tool provides a powerful failure processing mechanism, which can be defined by a FailAction parameter and comprises three fault-tolerant mechanisms of ignoring exception continuation, encountering exception exit and breakpoint resuming, and the processing modes aiming at the three fault-tolerant mechanisms are as follows:
ignoring exception handling: calling the API to execute the SQL statement to report errors, ignoring the error, and continuing to execute.
Processing mode of abnormal exit: calling the API to execute the SQL statement to report errors, and exiting the current Operation thread.
And thirdly, a processing mode of breakpoint continuous transmission: the core of the power-off continuous transmission is to divide SQL sentences to be executed into pieces and then use multiple threads to execute concurrently, so that Expects in each Operation need to define multiple threads, an SQL file is divided into each thread according to marks to analyze and execute, the SQL sentences are marked in the SQL file, sentences needing to be executed in the same group in sequence need to be put in one group, after different Expects are executed and error is reported, the executed sentences can be returned by the current thread, then the current thread enters a waiting state, a tag file is output by a tool as a waiting mark, after a change person finishes modifying the wrong SQL sentences, the tag file is deleted, the Expects can read the sentence sections in the SQL file again, and then the sentences are executed again. The flow is shown in fig. 4.
It should be noted that, the connection of different types of databases (Oracle database, Gauss database, SQLite database) can be established by defining the Usage parameter, which is very convenient in terms of database expansion.
Second, the database execution tool of Python version: and performing database change based on the SQLPlus, wherein database change operations which cannot be performed by JDBC, such as commands for importing and exporting databases, such as imp and exp, can be completed as a supplementary version of the java tool.
Based on the same inventive concept, the embodiment of the present invention further provides a database statement execution apparatus, as described in the following embodiments. Because the principle of the device for solving the problems is similar to the database statement execution method, the implementation of the device can refer to the implementation of the database statement execution method, and repeated parts are not described again.
Fig. 5 is a schematic diagram of a database statement executing apparatus according to an embodiment of the present invention, as shown in fig. 5, the apparatus includes: a configuration file acquisition module 51, a database statement generation module 52 and a database statement execution module 53.
The configuration file obtaining module 51 is configured to obtain a database change configuration file, where the database change configuration file includes: database information of a database to be changed and preset database operation executed by the database to be changed; a database statement generating module 52, configured to generate a database statement for executing a preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation; and the database statement execution module 53 is configured to execute a database statement for executing a preset database operation on the database to be changed.
As can be seen from the above, the database statement execution device provided in the embodiment of the present invention configures, in a data change configuration file, database information of a database to be changed and a preset database operation executed by the database to be changed, further generates, according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation, a database statement for executing the preset database operation on the database to be changed, and finally executes the database statement for executing the preset database operation on the database to be changed, so as to implement change of the database to be changed. The embodiment of the invention can simultaneously support the change of various types of databases, does not need to log in a plurality of machines to realize the change of the plurality of databases, and greatly improves the database change efficiency.
In an embodiment, in the database statement execution apparatus provided in the embodiment of the present invention, when a preset database operation executed on a database to be changed includes a plurality of database operations, the database change configuration file further includes: the execution mode and the concurrency number, the execution mode comprises: the method includes performing in series for performing the respective database operations in a serial manner and performing in parallel for performing the respective database operations in a parallel manner.
In an embodiment, when the execution manner in the database change configuration file is parallel execution, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module 53 is further configured to: and starting threads with corresponding concurrent number from the thread pool, and executing database statements of each database operation in a parallel mode.
In an embodiment, as shown in fig. 6, the database statement execution apparatus provided in the embodiment of the present invention further includes: an execution state monitoring module 54, configured to monitor an execution state of executing each database operation on the database to be changed, where the execution state includes: not started, in execution, successful execution, and failed execution.
In an embodiment, in the database statement execution apparatus provided in the embodiment of the present invention, the execution status monitoring module 54 is further configured to: and when monitoring that the execution of any database operation executed by the database to be changed fails, determining the execution state of the database to be changed as the execution failure.
In an embodiment, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module 53 is further configured to: and when the situation that the execution of any one database operation executed by the database to be changed fails is monitored, continuously executing database statements corresponding to other database operations.
In an embodiment, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module 53 is further configured to: and when the situation that the execution of any database operation executed by the database to be changed fails is monitored, quitting the thread for executing the corresponding database statement.
In an embodiment, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module 53 is further configured to: when monitoring that any one database operation executed by the database to be changed fails to be executed, marking a database statement which fails to be executed; and under the condition that the database statement which fails to be executed is corrected, re-executing the corrected database statement.
In an embodiment, in the database statement execution apparatus provided in the embodiment of the present invention, the database change configuration file is a configuration file in a Json format.
In an embodiment, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module 53 is further configured to: and calling a JDBC API tool to execute a database statement for executing preset database operation on the database to be changed.
In an embodiment, in the database statement execution apparatus provided in the embodiment of the present invention, the database statement execution module 53 is further configured to: and calling an SQL Plus tool to execute a database statement for executing preset database operation on the database to be changed.
Based on the same inventive concept, the embodiment of the present invention further provides an embodiment of an electronic device for implementing all or part of the contents in the database statement execution method. The electronic device specifically comprises the following contents:
a processor (processor), a memory (memory), a communication Interface (Communications Interface), and a bus; the processor, the memory and the communication interface complete mutual communication through the bus; the communication interface is used for realizing information transmission between related devices; the electronic device may be a desktop computer, a tablet computer, a mobile terminal, and the like, but the embodiment is not limited thereto. In this embodiment, the electronic device may be implemented with reference to the embodiment for implementing the database statement execution method and the embodiment for implementing the database statement execution apparatus in the embodiments, and the contents thereof are incorporated herein, and repeated details are not repeated herein.
Fig. 7 is a schematic diagram of a system configuration structure of an electronic device according to an embodiment of the present invention. As shown in fig. 7, the electronic device 70 may include a processor 701 and a memory 702; a memory 702 is coupled to the processor 701. Notably, this fig. 7 is exemplary; other types of structures may also be used in addition to or in place of the structure to implement telecommunications or other functions.
In one embodiment, the functions of the database statement execution method implementation may be integrated into the processor 701. Wherein, the processor 701 may be configured to control as follows: acquiring a database change configuration file, wherein the database change configuration file comprises: database information of a database to be changed and preset database operation executed by the database to be changed; generating a database statement for executing preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation; and executing the database statement for executing the preset database operation on the database to be changed.
As can be seen from the above, in the electronic device provided in the embodiment of the present invention, the database information of the database to be changed and the preset database operation executed by the database to be changed are configured in the data change configuration file, and then according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation, the database statement for executing the preset database operation on the database to be changed is generated, and finally, the database statement for executing the preset database operation on the database to be changed is executed, so as to implement the change of the database to be changed. The embodiment of the invention can simultaneously support the change of various types of databases, does not need to log in a plurality of machines to realize the change of the plurality of databases, and greatly improves the database change efficiency.
In another embodiment, the database statement execution device may be configured separately from the processor 701, for example, the database statement execution device may be configured as a chip connected to the processor 701, and the function of the database statement execution method is realized by the control of the processor.
As shown in fig. 7, the electronic device 70 may further include: a communication module 703, an input unit 704, an audio processing unit 705, a display 706, and a power supply 707. It is noted that the electronic device 70 does not necessarily include all of the components shown in fig. 7; furthermore, the electronic device 70 may also comprise components not shown in fig. 7, which can be referred to in the prior art.
As shown in fig. 7, the processor 701, which is sometimes referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, and the processor 701 receives input and controls the operation of the various components of the electronic device 70.
The memory 702 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The information relating to the failure may be stored, and a program for executing the information may be stored. And the processor 701 may execute the program stored in the memory 702 to realize information storage or processing, or the like.
The input unit 704 provides input to the processor 701. The input unit 704 is, for example, a key or a touch input device. The power supply 707 is used to supply power to the electronic device 70. The display 706 is used for displaying display objects such as images and characters. The display may be, for example, an LCD display, but is not limited thereto.
The memory 702 may be a solid state memory such as Read Only Memory (ROM), Random Access Memory (RAM), a SIM card, or the like. There may also be a memory that holds information even when power is off, can be selectively erased, and is provided with more data, an example of which is sometimes called an EPROM or the like. The memory 702 may also be some other type of device. Memory 702 includes a buffer memory 7021 (sometimes referred to as a buffer). The memory 702 may include an application/function storage portion 7022, the application/function storage portion 7022 being used to store application programs and function programs or procedures for performing operations of the electronic device 70 by the processor 701.
The memory 702 may also include a data store 7023, the data store 7023 being for storing data, such as contacts, digital data, pictures, sounds, and/or any other data used by the electronic device. The driver storage portion 7024 of the memory 702 may include various drivers of the electronic device for communication functions and/or for performing other functions of the electronic device (e.g., messaging application, address book application, etc.).
The communication module 703 is a transmitter/receiver that transmits and receives signals via the antenna 708. A communication module (transmitter/receiver) 703 is coupled to the processor 701 to provide an input signal and receive an output signal, which may be the same as in the case of a conventional mobile communication terminal.
Based on different communication technologies, a plurality of communication modules 703, such as a cellular network module, a bluetooth module, and/or a wireless local area network module, may be provided in the same electronic device. The communication module (transmitter/receiver) 703 is also coupled to a speaker 709 and a microphone 710 via an audio processing unit 705 to provide audio output via the speaker 709 and receive audio input from the microphone 710 to implement general telecommunication functions. The audio processing unit 705 may include any suitable buffers, decoders, amplifiers and so forth. Additionally, an audio processing unit 705 is also coupled to the processor 701 to enable recording of sound locally through a microphone 710 and to enable playing of locally stored sound through a speaker 709.
An embodiment of the present invention further provides a computer-readable storage medium for implementing all the steps in the database statement execution method in the foregoing embodiments, where the computer-readable storage medium stores thereon a computer program, and when the computer program is executed by a processor, the computer program implements all the steps in the database statement execution method in the foregoing embodiments, for example, when the processor executes the computer program, the processor implements the following steps: acquiring a database change configuration file, wherein the database change configuration file comprises: database information of a database to be changed and preset database operation executed by the database to be changed; generating a database statement for executing preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation; and executing the database statement for executing the preset database operation on the database to be changed.
As can be seen from the above, in the computer-readable storage medium provided in the embodiment of the present invention, the database information of the database to be changed and the preset database operation executed by the database to be changed are configured in the data change configuration file, and further, according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation, a database statement for executing the preset database operation on the database to be changed is generated, and finally, the database statement for executing the preset database operation on the database to be changed is executed, so as to implement the change of the database to be changed. The embodiment of the invention can simultaneously support the change of various types of databases, does not need to log in a plurality of machines to realize the change of the plurality of databases, and greatly improves the database change efficiency.
Although the present invention provides method steps as described in the examples or flowcharts, more or fewer steps may be included based on routine or non-inventive labor. 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 client product executes, it may execute sequentially or in parallel (e.g., in the context of parallel processors or multi-threaded processing) according to the embodiments or methods shown in the figures.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, apparatus (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, 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 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 document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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. The terms "upper", "lower", and the like, indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience in describing the present invention and simplifying the description, but do not indicate or imply that the referred devices or elements must have a specific orientation, be constructed and operated in a specific orientation, and thus, should not be construed as limiting the present invention. Unless expressly stated or limited otherwise, the terms "mounted," "connected," and "connected" are intended to be inclusive and mean, for example, that they may be fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations. It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict. The present invention is not limited to any single aspect, nor is it limited to any single embodiment, nor is it limited to any combination and/or permutation of these aspects and/or embodiments. Each aspect and/or embodiment of the invention can be used alone or in combination with one or more other aspects and/or embodiments.
The above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the present invention, and they should be construed as being included in the following claims and description.

Claims (24)

1. A database statement execution method, comprising:
acquiring a database change configuration file, wherein the database change configuration file comprises: database information of a database to be changed and preset database operation executed by the database to be changed;
generating a database statement for executing preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation;
and executing the database statement for executing the preset database operation on the database to be changed.
2. The method of claim 1, wherein when the predetermined database operation performed on the database to be changed comprises a plurality of database operations, the database change configuration file further comprises: the method comprises the following steps of: serial execution for performing the respective database operations in a serial manner, and parallel execution for performing the respective database operations in a parallel manner.
3. The method of claim 2, wherein when the manner of execution in the database change profile is in parallel, the method further comprises:
and starting threads with corresponding concurrent number from the thread pool, and executing database statements of each database operation in a parallel mode.
4. The method of claim 3, wherein after executing the database statement that performs the preset database operation on the database to be changed, the method further comprises:
monitoring an execution state of executing each database operation on a database to be changed, wherein the execution state comprises: not started, in execution, successful execution, and failed execution.
5. The method of claim 4, wherein the method further comprises:
and when monitoring that any one database operation executed by the database to be changed fails to be executed, determining the execution state of the database to be changed as the execution failure.
6. The method of claim 4, wherein the method further comprises:
and when the situation that the execution of any one database operation executed by the database to be changed fails is monitored, continuously executing database statements corresponding to other database operations.
7. The method of claim 4, wherein the method further comprises:
and when the situation that the execution of any database operation executed by the database to be changed fails is monitored, quitting the thread for executing the corresponding database statement.
8. The method of claim 4, wherein the method further comprises:
when monitoring that any one database operation executed by the database to be changed fails to be executed, marking a database statement which fails to be executed;
and under the condition that the database statement which fails to be executed is corrected, re-executing the corrected database statement.
9. The method of any of claims 1 to 6, wherein the database change profile is a Json format profile.
10. The method of claim 9, wherein executing the database statement that performs the preset database operation on the database to be changed comprises:
and calling a JDBC API tool to execute a database statement for executing preset database operation on the database to be changed.
11. The method of claim 9, wherein executing the database statement that performs the preset database operation on the database to be changed comprises:
and calling an SQL Plus tool to execute a database statement for executing preset database operation on the database to be changed.
12. A database statement execution apparatus, comprising:
a configuration file obtaining module, configured to obtain a database change configuration file, where the database change configuration file includes: database information of a database to be changed and preset database operation executed by the database to be changed;
the database statement generating module is used for generating a database statement for executing the preset database operation on the database to be changed according to the database information of the database to be changed and the preset database statement corresponding to the preset database operation;
and the database statement execution module is used for executing the database statement for executing the preset database operation on the database to be changed.
13. The apparatus of claim 12, wherein when the predetermined database operation performed on the database to be changed comprises a plurality of database operations, the database change configuration file further comprises: the method comprises the following steps of: serial execution for performing the respective database operations in a serial manner, and parallel execution for performing the respective database operations in a parallel manner.
14. The apparatus of claim 13, wherein in the case that the execution mode in the database change configuration file is parallel execution, the database statement execution module is further configured to: and starting threads with corresponding concurrent number from the thread pool, and executing database statements of each database operation in a parallel mode.
15. The apparatus of claim 14, wherein the apparatus further comprises:
the execution state monitoring module is used for monitoring the execution state of executing each database operation on the database to be changed, wherein the execution state comprises the following steps: not started, in execution, successful execution, and failed execution.
16. The apparatus of claim 15, wherein the execution status monitoring module is further to:
and when monitoring that any one database operation executed by the database to be changed fails to be executed, determining the execution state of the database to be changed as the execution failure.
17. The apparatus of claim 15, wherein the database statement execution module is further to:
and when the situation that the execution of any one database operation executed by the database to be changed fails is monitored, continuously executing database statements corresponding to other database operations.
18. The apparatus of claim 15, wherein the database statement execution module is further to:
and when the situation that the execution of any database operation executed by the database to be changed fails is monitored, quitting the thread for executing the corresponding database statement.
19. The apparatus of claim 15, wherein the database statement execution module is further to:
when monitoring that any one database operation executed by the database to be changed fails to be executed, marking a database statement which fails to be executed;
and under the condition that the database statement which fails to be executed is corrected, re-executing the corrected database statement.
20. The apparatus of any of claims 12 to 19, wherein the database change profile is a Json format profile.
21. The apparatus of claim 20, wherein the database statement execution module is further to:
and calling a JDBC API tool to execute a database statement for executing preset database operation on the database to be changed.
22. The apparatus of claim 20, wherein the database statement execution module is further to:
and calling an SQL Plus tool to execute a database statement for executing preset database operation on the database to be changed.
23. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the database statement execution method according to any one of claims 1 to 11 when executing the computer program.
24. A computer-readable storage medium storing a computer program for executing the database statement execution method according to any one of claims 1 to 11.
CN202110188756.3A 2021-02-19 2021-02-19 Database statement execution method and device Pending CN113157711A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110188756.3A CN113157711A (en) 2021-02-19 2021-02-19 Database statement execution method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110188756.3A CN113157711A (en) 2021-02-19 2021-02-19 Database statement execution method and device

Publications (1)

Publication Number Publication Date
CN113157711A true CN113157711A (en) 2021-07-23

Family

ID=76883822

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110188756.3A Pending CN113157711A (en) 2021-02-19 2021-02-19 Database statement execution method and device

Country Status (1)

Country Link
CN (1) CN113157711A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114328719A (en) * 2021-11-30 2022-04-12 唯品会(广州)软件有限公司 Database statement synchronization method, system, electronic device and computer-readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114328719A (en) * 2021-11-30 2022-04-12 唯品会(广州)软件有限公司 Database statement synchronization method, system, electronic device and computer-readable storage medium

Similar Documents

Publication Publication Date Title
CN112380180A (en) Data synchronization processing method, device, equipment and storage medium
CN112783793B (en) Automatic interface test system and method
CN112256581B (en) Log playback test method and device for high-simulation securities trade trading system
CN110543301B (en) Method and device for generating jenkins code file
US11675690B2 (en) Lineage-driven source code generation for building, testing, deploying, and maintaining data marts and data pipelines
CN110198327B (en) Data transmission method and related equipment
CN110737594A (en) Database standard conformance testing method and device for automatically generating test cases
CN111949832A (en) Method and device for analyzing dependency relationship of batch operation
CN113157711A (en) Database statement execution method and device
CN112783867A (en) Database optimization method for meeting real-time big data service requirements and cloud server
CN113238965B (en) Interface test script generation method, system and storage medium
CN112860585B (en) Test script assertion generation method and device
CN112988600A (en) Service scene testing method and device, electronic equipment and storage medium
CN116860781A (en) Data verification method, device, terminal equipment and storage medium
CN113672674A (en) Method, electronic device and storage medium for automatically arranging service flow
US7464363B2 (en) Verification support device, verification support method, and computer product
CN111339100B (en) Data checking method and device
CN114968917A (en) Method and device for rapidly importing file data
CN114676113A (en) Heterogeneous database migration method and system based on task decomposition
CN111782641A (en) Data error repairing method and system
CN113535575A (en) Benchmark testing method and device for basic environment of software and hardware product
CN112487006A (en) Implementation method for dynamically editing data structure and generating database table
CN112000671A (en) Block chain-based database table processing method, device and system
CN111459583A (en) Menu creating method and device
CN113419957B (en) Rule-based big data offline batch processing performance capacity scanning method and device

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