CN115701599A - Database changing method and device, electronic equipment and storage medium - Google Patents

Database changing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115701599A
CN115701599A CN202110880428.XA CN202110880428A CN115701599A CN 115701599 A CN115701599 A CN 115701599A CN 202110880428 A CN202110880428 A CN 202110880428A CN 115701599 A CN115701599 A CN 115701599A
Authority
CN
China
Prior art keywords
change
database
content
verification
changed
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
CN202110880428.XA
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.)
NetsUnion Clearing Corp
Original Assignee
NetsUnion Clearing 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 NetsUnion Clearing Corp filed Critical NetsUnion Clearing Corp
Priority to CN202110880428.XA priority Critical patent/CN115701599A/en
Publication of CN115701599A publication Critical patent/CN115701599A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a database change method, a database change device, electronic equipment and a storage medium, which are executed by a database change platform server, wherein the method comprises the following steps: receiving a database change request, wherein the database change request comprises change content; verifying the change content to obtain the change content passing verification, wherein the verification comprises performability verification and quality verification; verifying the change contents passing the verification according to a change verification strategy to obtain the change contents passing the verification; and executing the change content passing the verification according to the change execution strategy so as to complete the database change. According to the database changing method, the database changing operation can be automatically executed according to the actual requirements of the user through the database changing platform which is established in advance, and the timeliness of database changing is improved; meanwhile, the double verification of performability and quality is carried out on the changed content, and the self-service changing efficiency of the database is further optimized.

Description

Database changing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of database technologies, and in particular, to a database changing method and apparatus, an electronic device, and a storage medium.
Background
Conventional Database changes are usually implemented by a Database Administrator (DBA) manually operating a data source to execute SQL (Structured Query Language) statements.
However, the inventor finds that the method has the problems of large manual review amount, difficulty in changing the specification, low timeliness of changing and the like, and manual execution of DBA change is easy to face the risk of manual operation, thereby causing great threat to the production environment.
Disclosure of Invention
The embodiment of the application provides a database changing method and device, electronic equipment and a storage medium, so that the database changing efficiency is improved, and the safety of database changing is ensured.
The embodiment of the application adopts the following technical scheme:
in a first aspect, an embodiment of the present application provides a database change method, which is executed by a database change platform server, where the method includes:
receiving a database change request, wherein the database change request comprises change content;
verifying the changed contents to obtain the changed contents passing the verification, wherein the verification comprises executable verification and quality verification;
verifying the change contents passing the verification according to a change verification strategy to obtain the change contents passing the verification;
and executing the change content passing the verification according to the change execution strategy so as to complete the database change.
Optionally, the verifying the changed content, and obtaining the changed content that passes the verification includes:
performing executable verification on the changed content by utilizing an inclusion automatic operation and maintenance tool;
under the condition that the changed content is executable, performing quality verification on the changed content to obtain the changed content passing the verification according to a quality verification result;
and under the condition that the changed content is not executable, directly optimizing the changed content by using an SQL optimization tool to obtain the changed content passing the verification.
Optionally, the performing quality check on the modified content to obtain the modified content passing the check according to the quality check result includes:
performing quality verification on the changed content by using an SQL (structured query language) optimization tool, wherein the quality verification comprises one or more of a Where condition, an aggregation condition, a multi-table connection relation and a multi-column index to obtain a quality inspection result;
when the quality inspection result is that the quality inspection is passed, directly taking the change content as the change content passed by the quality inspection;
and outputting an SQL statement optimization suggestion under the condition that the quality inspection result is that the quality inspection fails, so as to obtain the change content passing the inspection according to the SQL statement optimization suggestion.
Optionally, the change content includes change SQL, and the verifying the change content to obtain the change content that passes the verification includes:
determining a change type for changing the SQL by using the Druid database connection pool component;
and checking the changed SQL according to the change type of the changed SQL to obtain the changed SQL which passes the check.
Optionally, the change type of the change SQL includes a DML type, and after the change content is checked to obtain the change content that is checked, the method further includes:
and under the condition that the verification fails, generating a rollback statement according to the change SQL of the DML type.
Optionally, after the modified content is verified to obtain a verified modified content, the method further includes:
generating a change order according to the change content so as to complete database change by executing the change order;
the change list comprises N pieces of change content corresponding to M data sources, wherein N and M are integers, and N is not less than M.
Optionally, the changing and auditing policy includes a changing and auditing process, and the auditing the changed content according to the changing and auditing policy to obtain the changed content that passes the auditing includes:
determining a change type and a change auditing process corresponding to the change type according to the database change request;
and triggering the change auditing process so that an auditing platform audits the changed content according to the change auditing process.
Optionally, the executing the change content that passes the audit according to the change execution policy includes:
determining a target execution strategy according to the database change request;
and under the condition that the target execution strategy is an automatic execution strategy, automatically executing the changed contents which are passed by the examination according to a preset execution time interval.
Optionally, after executing the audited changed content according to a change execution policy, the method further includes:
acquiring an execution result of the changed content;
generating a database change record according to the execution result of the change content, wherein the database change record comprises one or more of audit information, execution information, change time, change influence and operators of the change content;
and performing statistical analysis on the database change records, and generating a database change report according to the statistical analysis result.
Optionally, the method further comprises:
providing a front-end page;
the receiving a database change request comprises:
and receiving the database change request through the front-end page.
In a second aspect, an embodiment of the present application further provides a database modification apparatus, which is applied to a database modification platform server, where the apparatus is configured to implement any one of the foregoing methods.
In a third aspect, an embodiment of the present application further provides an electronic device, including:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to perform any of the methods described above.
In a fourth aspect, embodiments of the present application further provide a computer-readable storage medium storing one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to perform any of the methods described above.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects: the database change method of the embodiment of the application can be executed by the database change platform server, and when the database is changed, a database change request can be received first, wherein the database change request comprises change content; then, the change content is verified to obtain the change content passing the verification, and the verification comprises performability verification and quality verification; verifying the verified changed contents according to the changed verifying strategy to obtain the verified changed contents; and executing the change content passing the verification according to the change execution strategy so as to complete the database change. According to the database changing method, the database changing operation can be automatically executed according to the actual requirements of the user through the database changing platform which is established in advance, and the timeliness of database changing is improved; meanwhile, the double verification of performability and quality is carried out on the changed content, and the self-service changing efficiency of the database is further optimized.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a schematic flow chart illustrating a database modification method according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram illustrating a database modification process according to an embodiment of the present application;
FIG. 3 is a schematic structural diagram of a database modification apparatus according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, 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 application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Under the background of rapid development of the internet, a business side has a need to frequently improve the product quality of a database so as to improve the use experience of a user. In an actual service scenario, the change operation performed by the service party on the database may mainly include: the change of the table structure is, for example, a change of a Data Definition Language (DDL), a change of table Data is, for example, a change of a Data Manipulation Language (DML), a change of table authority is, for example, a Data Control Language (DCL), and the like. For example, when a service newly increases query requirements, in order to avoid full table scanning, an index is added to an original table; when the service is changed, newly adding a field or lengthening an original field in an original table; in order to avoid the data from growing too fast, the historical data in the database needs to be cleaned regularly, and the like.
In the database change method in the prior art, an application team provides database change contents to a DBA (database administration server), the DBA manually checks the correctness, safety and normalization of the database change contents, and the database change contents are manually executed after the check is passed.
However, this method has the following problems:
1) With the continuous expansion of business, the database change requirements submitted by application teams are increasing day by day, and the working mode of a limited DBA for processing a large number of change requirements cannot meet the requirement of change timeliness.
2) The DBA has large manual review amount, and the standard change and supervision constraint landing are difficult;
3) The database has large changing risk and high business correlation, all online business problems cannot be solved only by examining and executing the database changing content by the DBA, and the risk of manual operation exists.
Based on this, an embodiment of the present application provides a database change method, which is executed by a database change platform server, and as shown in fig. 1, provides a flowchart of the database change method in the embodiment of the present application, where the method at least includes the following steps S110 to S140:
step S110, receiving a database change request, where the database change request includes change content.
The database change method of the embodiment of the application can be executed by a server where a database change platform which is deployed independently is located, and the database change platform can be regarded as a platform for performing centralized processing and management on the change of the database.
When the database is changed, a database change request may be received through the database change platform, where the database change request carries contents of the database change, that is, the database change request may be used to indicate which database the user wants to perform which changes on.
Step S120, verifying the modified content to obtain modified content passing verification, where the verification includes performability verification and quality verification.
After receiving the database change request, the change content in the database change request may be checked, where the check may include two dimensions, one is an enforceability check of the change content, i.e., whether the change content can be executed, and one is a quality check of the change content, i.e., how the change content, if it can be executed, is expected to perform.
After the verification of the two dimensions, the change content passing the verification can be obtained, the change content meets both the feasibility requirement and the quality requirement, the subsequent verification efficiency is improved, and the verification pressure is reduced.
And step S130, auditing the change contents which pass the verification according to the change auditing strategy to obtain the change contents which pass the auditing.
In order to further ensure the accuracy of the changed content of the database and avoid the influence on subsequent services, in the embodiment of the present application, after the changed content that passes the verification is obtained, the changed content of the database needs to be checked according to the change checking policy, whether the changed content meets the requirements of actual services and the like is checked, and the subsequent database changing operation can be executed only after the check is passed.
Step S140, executing the change content that passes the audit according to the change execution policy to complete the database change.
For the change contents which pass the verification, the change execution strategy which is set in advance can be used for executing the change contents, and then the whole database change process is completed.
According to the database changing method, the database changing operation can be automatically executed according to the actual requirements of the user through the database changing platform which is established in advance, and the timeliness of database changing is improved; meanwhile, the double verification of performability and quality is carried out on the changed content, and the self-service changing efficiency of the database is further optimized.
In an embodiment of the application, the verifying the changed content, and obtaining the changed content that passes the verification includes: performing executable verification on the changed content by utilizing an inclusion automatic operation and maintenance tool; under the condition that the changed content is executable, performing quality check on the changed content to obtain the changed content passing the quality check according to a quality check result; and under the condition that the changed content is not executable, directly optimizing the changed content by using an SQL (structured query language) optimization tool to obtain the changed content which passes the verification.
In an actual business scenario, the change performed on the database is mainly implemented by a changed SQL (Structured Query Language) statement, and therefore, the change content herein may include the changed SQL. The database of the embodiment of the application can adopt any database supporting the SQL statements, such as a MySQL database.
As described above, in the embodiment of the application, when the verification is performed on the change content, two dimensions, namely, the feasibility verification and the quality verification, are included, when the feasibility verification is performed, the inclusion automation operation and maintenance tool may be used to perform pre-execution on the change content, and then, whether the change content is executable or not may be determined according to a pre-execution result, if the pre-execution is passed, the change content is executable, that is, the performability verification is passed, and if the pre-execution is not passed, the change content is mainly determined to be not executable, that is, the performability verification is not passed, if the pre-execution is not passed, that is, the change content is mainly determined to be in error in execution, or the execution result is incorrect, and the like.
In the case that the alteration content passes the performability check, in order to further improve the accuracy of the alteration content, the alteration content may be subjected to quality analysis, and then it is determined whether the alteration content passes a final check according to the result of the quality analysis, for example, if the quality analysis is qualified, it may be determined that the alteration content passes a double check of performability and quality, and if the quality analysis is not qualified, it may be determined that the alteration content passes the performability check but does not meet the quality requirement, and further optimization is required.
When the changed content fails the performability check, the changed content is described as being unable to be executed or unable to be executed correctly, and the changed content can be optimized by directly utilizing an SQL optimization tool, so that the changed content passing the check can be obtained.
In an embodiment of the application, the performing quality check on the modified content to obtain the modified content that passes the check according to the quality check result includes: performing quality check on the changed content by using an SQL optimization tool, wherein the quality check comprises one or more of a Where condition, an aggregation condition, a multi-table connection relation and a multi-column index, and obtaining a quality check result; when the quality inspection result is that the quality inspection is passed, directly taking the change content as the change content passed by the quality inspection; and outputting an SQL statement optimization suggestion under the condition that the quality inspection result is that the quality inspection fails, so as to obtain the change content passing the inspection according to the SQL statement optimization suggestion.
When the quality of the changed content is checked, the embodiment of the application can also be realized by using an SQL optimization tool, including checking compliance checking of Where conditions, aggregation conditions, multi-table connection relations, multi-column indexes and the like in the changed SQL statement.
The SQL optimization tool can specifically adopt SQL Advisor or SOAR and other tools, the SQL Advisor analyzes based on MySQL primitive lexical method, and finally outputs the optimal index optimization suggestion by combining with Where conditions, field selectivity, aggregation conditions, multi-table Join relations and the like in SQL. SOAR (SQL Optimizer And Rewriter) is also an automatic tool for optimizing And rewriting SQL, and supports statement optimization based on heuristic algorithm, multi-column index optimization of complex query, SQL rewriting of custom rule And the like. Of course, which type of SQL optimization tool is specifically used may be flexibly selected by a person skilled in the art according to actual requirements, and is not limited specifically herein.
The quality of the changed content can be evaluated according to whether the SQL optimization tool outputs the optimization suggestion, generally, when the quality of the changed content does not meet the quality requirement, the SQL optimization tool outputs the optimization suggestion, so that the changed content can be further optimized according to the optimization suggestion, the changed content passing the verification is obtained, and when the quality of the changed content meets the quality requirement, the SQL optimization tool generally does not output the optimization suggestion, so that the changed content can be directly used as the changed content passing the verification.
In an embodiment of the present application, the modified content includes modified SQL, and the verifying the modified content to obtain modified content that passes the verification includes: determining a change type for changing the SQL by using the Druid database connection pool component; and checking the changed SQL according to the change type of the changed SQL to obtain the changed SQL which passes the check.
After receiving the change SQL, the change SQL can be divided and analyzed by using the managed database connection pool component, the change type of the change SQL is determined, for example, the change type is DML, DDL or DCL, and then the change SQL is verified according to the change type obtained by analysis, the method mainly comprises the steps of verifying the syntax of the change SQL, whether the change SQL meets the change specification of the actual service, and the like, and further the change SQL which passes the verification can be obtained according to the verification result.
In an embodiment of the application, the change type of the changed SQL includes a DML type, and after the change content is checked to obtain the change content that passes the check, the method further includes: and under the condition that the verification fails, generating a rollback statement according to the change SQL of the DML type.
If the syntax format or content of the changed SQL does not meet the corresponding syntax requirement, the changed SQL cannot be executed or an accurate execution result cannot be obtained, or the changed SQL does not meet the change specification and quality requirement of an actual business scene, the check is not passed, at the moment, if the type of the changed SQL is a DML type, a rollback statement can be correspondingly generated according to the changed SQL so as to stop loss in time by executing the rollback statement after subsequent change execution fails, and if the changed SQL is of other types, such as DDL and DCL, because the DDL and the DCL do not support rollback, the DBA can be notified to perform manual intervention for processing.
In an embodiment of the application, after the modified content is verified to obtain the modified content that is verified, the method further includes: generating a change order according to the change content so as to complete database change by executing the change order; the change list comprises N pieces of change content corresponding to M data sources, wherein N and M are integers, and N is not less than M.
For the change SQL which passes the verification, the syntax format, the content and the like of the change SQL are described to meet the requirement of performability, and simultaneously meet the change specification and the quality requirement of the actual business, so that a change list can be generated according to the change content to be used as the basis for carrying out change verification subsequently.
The change order in the embodiment of the application may be regarded as a set formed by all change SQL targeted by one data change request, and may specifically include a plurality of data sources and one or more change SQL corresponding to each data source, where a data source may be understood as a specific object that a user wants to perform a database change operation, and may be all data tables in a certain database, all fields in a certain data table, a certain field in a certain data table, and the like. Of course, the data source is subdivided into different dimensions, and those skilled in the art can flexibly set the dimensions according to actual needs, and the data source is not limited in detail here.
According to the embodiment of the application, the capability of executing a plurality of changed contents through one change list is provided through the database change platform, and the timeliness of database change is greatly improved.
The verification result obtained in the verification process of the embodiment can be recorded in the database change platform, so that reference can be provided for the follow-up auditor to audit the changed content.
In an embodiment of the application, the changing and auditing policy includes a changing and auditing process, and the auditing the changed content according to the changing and auditing policy includes: determining a change type and a change auditing process corresponding to the change type according to the database change request; and triggering the change auditing process so as to enable an auditing platform to audit the change content according to the change auditing process.
Different change types such as daily DML, daily DDL, daily DCL, emergency change and the like can be set according to actual business requirements in the database change platform of the embodiment of the application, and usually, change auditing strategies corresponding to different types of change contents are different.
When the change type and the change auditing strategy corresponding to the change type are determined, the change type corresponding to the change content and the corresponding change auditing process can be determined according to the change content passing the verification, and then an auditing notice can be sent to the corresponding change auditing personnel, so that the change auditing personnel can log in the database change platform in time and audit the change content according to the corresponding change auditing process.
The auditing result can comprise an auditing passing result or an auditing failing result, the changing content passing the auditing can be subjected to subsequent changing content executing operation, the changing content failing the auditing can not be subjected to executing operation, and manual intervention can be notified for processing. Whether the result of the audit is passed or not is recorded in the audit record of the database change platform correspondingly for archiving, so as to provide a reference for the optimization of the subsequent database change.
In an embodiment of the application, the executing the change content that passes the audit according to the change execution policy includes: determining a target execution strategy according to the database change request; and under the condition that the target execution strategy is an automatic execution strategy, automatically executing the changed contents which pass the examination according to a preset execution time interval.
The database change platform of the embodiment of the application can be preset with different change execution strategies, for example, the strategy can be automatically executed by the platform, the manual operation cost and the misoperation risk can be reduced, and the user can trigger execution operation according to actual requirements, so that the flexibility of the database change process is improved.
When the change content which is checked is executed according to the change execution strategy, the target execution strategy selected by the user can be determined firstly, and the result selected by the user can be carried in the database change request, so that whether the target execution strategy is the automatic execution strategy or not can be determined according to the database change request, if the target execution strategy is the automatic execution strategy, the change content which is checked is automatically executed according to the execution time interval which is set in the automatic execution strategy in advance, and the database change process is automatically completed.
Of course, in addition to the above automatic execution mode, the user may also select manual execution, and at this time, the platform background may execute the corresponding change SQL on the corresponding data source only when the user logs in the database change platform and clicks the execution button. No matter the platform is automatically executed or manually executed, the platform background is connected to the corresponding data source to execute the corresponding SQL change, DBA intervention is not needed, and the manual operation cost and the risk of manual misoperation are reduced.
In an embodiment of the application, after the change content that passes the audit is executed according to a change execution policy, the method further includes: acquiring an execution result of the changed content; generating a database change record according to the execution result of the change content, wherein the database change record comprises one or more of audit information, execution information, change time, change influence and operators of the change content; and performing statistical analysis on the database change records, and generating a database change report according to the statistical analysis result.
After the changed content that passes the verification is executed according to the target execution policy, the execution result of the changed content may be obtained, which may specifically include the result of successful execution or failed execution, execution time consumption, and the like. And then, further statistical analysis can be carried out on the database change records, and a database change report is generated.
Because the database change report retains all change detail information such as the auditing detail and the execution result of the change SQL, the contents can be fed back to the user so as to further improve the subsequent database change operation, and simultaneously provide good data reference for the subsequent formulation of a standardized change process, thereby realizing the overall control on the database change safety.
In an actual application scenario, after the change SQL statement is executed on the database, the obtained change effect may not meet the expected requirement, and thus there is a need to restore the state of the database to the state before the change. Based on this, in an embodiment of the application, after the execution of the change SQL is completed, a user can select to click a rollback button in the database change platform according to an actual execution effect, and then the platform background executes a rollback statement, so that the database can be restored to an original state, and the user can be notified after the rollback statement is executed, and meanwhile, important information such as execution time consumption, an influence line number, an operator and the like is recorded, thereby facilitating subsequent troubleshooting statistics.
In one embodiment of the present application, the method further comprises: providing a front-end page; the receiving a database change request comprises: and receiving the database change request through the front-end page.
The database change platform server in the embodiment of the application may further provide a front-end page, so that a user may trigger a database change request on the front-end page, for example, input or select a data source to be changed and change SQL on the front-end page. In addition, the contents of the database change records, the database change reports and the like in the embodiment can be displayed on a front-end page, and the visualization requirements of users are met.
Fig. 2 is a schematic diagram of a database modification process in the embodiment of the present application. The database change process of the embodiment of the application mainly comprises three stages of new creation, verification, auditing and execution, and in the new creation stage, a database change request of a user is received through a front-end page of a database change platform, and the database change request specifically comprises information such as a data source and change SQL.
In the verification stage, verification on the changed SQL is automatically triggered according to a received database change request, wherein the verification comprises executable verification and quality verification, if the verification is not passed, a user is guided to refill the front-end page to obtain the executable changed SQL with higher quality, the verification result is recorded in a database change platform, and then a change list is created according to the change content passed by the verification to serve as the basis of subsequent change verification.
In the auditing stage, the change type corresponding to the change content which passes the verification, such as daily DML, daily DDL, daily DCL, emergency change and the like, is determined, then different change auditing strategies are triggered according to different change types, and then the change content can be audited according to the change auditing process corresponding to the change auditing strategies, so as to obtain the result that the auditing is passed or the auditing is not passed. And the change content which is not passed through the auditing can be directly stored in the database change record for archiving so as to be used as an improved basis for subsequent database change. The change content passing the audit can be subjected to subsequent execution operation.
In the execution stage, it may further be determined whether an execution policy for changing the content selected by the user on the front-end page is, for example, an automatic execution policy, and if the execution policy is the automatic execution policy, the newly created change ticket may be regarded as a timing work ticket, the change content in the change ticket may be executed at a predetermined timing according to a preset time, and the execution result may also be recorded in the database change record, thereby completing the whole database change process.
In order to facilitate understanding of the foregoing embodiments, the present application provides a database change process in an actual application scenario, and assuming that an application team wants to execute a change SQL on a 01 data table in a database a, where the change SQL means a column inserted into the 01 data table, the application team may input the change content on a front-end page provided by a database change platform of the present application. And then the database change platform automatically checks the changed SQL, for example, the changed SQL can be pre-executed by using an inclusion automatic operation and maintenance tool so as to obtain an executable check result, if the execution is executable, the changed SQL can be further analyzed by using SQL Advisor so as to realize semantic check on the changed SQL, and if the syntax structure is detected to be not in accordance with the quality requirement, prompt information of error content can be generated, an optimization suggestion is displayed on an interface, and the prompt information is provided for a team to refer and modify.
After the verification is passed, the database change platform may further determine the type of the change SQL, and since the change SQL is intended to be inserted into a data table, it may be determined that the change SQL is of a DDL type, and then a change auditing policy corresponding to the DDL type may be invoked accordingly, for example, the change SQL is audited according to a change auditing flow corresponding to the DDL type.
After the audit is passed, the change SQL meets the execution condition, the application team can manually click an execution button on the database change platform, a column can be inserted into the 01 data table after the execution is successful, or the application team can select an automatic execution strategy on the database change platform, so that the database change platform can automatically execute the change SQL at regular time according to the preset time after the change content audit is passed, and the automatic change process of the database is completed.
By integrating the above embodiments, the database changing method of the present application achieves at least the following technical effects:
1) According to the database change method, the database change platform is established in advance, so that a user can directly trigger a database change request on the database change platform, the platform can automatically check the SQL, an application team is guided to be changed correctly through humanized prompt, and manual intervention of a DBA is not needed.
2) The database change method provided by the application carries out double verification of performability and quality on the changed content, thereby not only ensuring that the changed content can be executed, but also ensuring the expected effect after the changed content is executed, and greatly improving the accuracy and safety of subsequent database change.
3) According to the database changing method, different auditing processes can be triggered according to different types of changing contents, and risks are controlled together by configuring the authority of auditors in advance. The execution strategy of the changed content can be further set to be automatically executed at regular time, so that the timeliness of database change is further improved, a user can directly execute the changed SQL by self through a platform according to actual requirements, DBA manual intervention is also not needed, and the risk of manual operation is reduced.
4) According to the database changing method, all changing details such as SQL changing, changing time, executing results, executing time consumption, influencing line number, operators and the like can be recorded through the database changing platform, namely, all operation traces can be exported, and a statistical analysis report can be exported, so that the database changing process can be better controlled, and the database changing risk is reduced.
The embodiment of the present application provides a database modification apparatus 300, which is applied to a database modification platform server, and as shown in fig. 3, provides a schematic structural diagram of the database modification apparatus according to the embodiment of the present application, where the apparatus 300 includes: a receiving unit 310, a checking unit 320, an auditing unit 330, and an executing unit 340, wherein:
a receiving unit 310, configured to receive a database change request, where the database change request includes change content;
a checking unit 320, configured to check the change content to obtain a change content that passes the check, where the check includes an executable check and a quality check;
the auditing unit 330 is configured to audit the change content that passes the verification according to the change auditing policy, so as to obtain the change content that passes the auditing;
and the executing unit 340 is configured to execute the change content that passes the audit according to the change execution policy, so as to complete the database change.
In an embodiment of the present application, the verification unit 320 is specifically configured to: performing performability verification on the change content by utilizing an inclusion automation operation and maintenance tool; under the condition that the changed content is executable, performing quality check on the changed content to obtain the changed content passing the quality check according to a quality check result; and under the condition that the changed content is not executable, directly optimizing the changed content by using an SQL optimization tool to obtain the changed content passing the verification.
In an embodiment of the present application, the verifying unit 320 is specifically configured to: performing quality check on the changed content by using an SQL optimization tool, wherein the quality check comprises one or more of a Where condition, an aggregation condition, a multi-table connection relation and a multi-column index, and obtaining a quality check result; when the quality inspection result is that the quality inspection is passed, directly taking the change content as the change content passed by the quality inspection; and outputting an SQL statement optimization suggestion under the condition that the quality inspection result is that the quality inspection fails, so as to obtain the change content passing the inspection according to the SQL statement optimization suggestion.
In an embodiment of the present application, the change content includes a change SQL, and the verification unit 320 is specifically configured to: determining a change type for changing the SQL by using the Druid database connection pool component; and checking the changed SQL according to the change type of the changed SQL to obtain the changed SQL which passes the check.
In an embodiment of the application, the change type of the change SQL includes a DML type, and the apparatus further includes: and the first generating unit is used for generating a rollback statement according to the change SQL of the DML type under the condition that the verification fails.
In one embodiment of the present application, the apparatus further comprises: a second generation unit, configured to generate a change order according to the change content, so as to complete database change by executing the change order; the change list comprises N pieces of change content corresponding to M data sources, wherein N and M are integers, and N is not less than M.
In an embodiment of the present application, the change auditing policy includes a change auditing process, and the auditing unit 330 is specifically configured to: determining a change type and a change auditing process corresponding to the change type according to the database change request; and triggering the change auditing process so that an auditing platform audits the changed content according to the change auditing process.
In an embodiment of the present application, the execution unit 340 is specifically configured to: determining a target execution strategy according to the database change request; and under the condition that the target execution strategy is an automatic execution strategy, automatically executing the changed contents which are passed by the examination according to a preset execution time interval.
In one embodiment of the present application, the apparatus further comprises: an acquisition unit configured to acquire an execution result of the change content; a third generating unit, configured to generate a database change record according to an execution result of the change content, where the database change record includes one or more of audit information, execution information, change time, change influence, and an operator of the change content; and the fourth generation unit is used for performing statistical analysis on the database change records and generating a database change report according to the statistical analysis result.
In one embodiment of the present application, the apparatus further comprises: a providing unit for providing a front-end page; the receiving unit 310 is specifically configured to: and receiving the database change request through the front-end page.
It can be understood that the database modification apparatus can implement the steps of the database modification method executed by the database modification platform server provided in the foregoing embodiment, and the explanations regarding the database modification method are applicable to the database modification apparatus, and are not repeated here.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Referring to fig. 4, at a hardware level, the electronic device includes a processor, and optionally further includes an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory, such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be connected to each other via an internal bus, which may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but that does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form the database changing device on the logic level. The processor is used for executing the program stored in the memory and is specifically used for executing the following operations:
receiving a database change request, wherein the database change request comprises change content;
verifying the change content to obtain the change content passing verification, wherein the verification comprises performability verification and quality verification;
verifying the change contents passing the verification according to a change verification strategy to obtain the change contents passing the verification;
and executing the change content passing the verification according to the change execution strategy so as to complete the database change.
The method executed by the database modification apparatus according to the embodiment shown in fig. 1 of the present application may be applied to a processor, or may be implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules may be located in ram, flash, rom, prom, or eprom, registers, etc. as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The electronic device may further execute the method executed by the database changing apparatus in fig. 1, and implement the functions of the database changing apparatus in the embodiment shown in fig. 1, which are not described herein again in this embodiment of the present application.
An embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium stores one or more programs, where the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to perform the method performed by the database change apparatus in the embodiment shown in fig. 1, and are specifically configured to perform:
receiving a database change request, wherein the database change request comprises change content;
verifying the changed contents to obtain the changed contents passing the verification, wherein the verification comprises executable verification and quality verification;
verifying the change contents passing the verification according to a change verification strategy to obtain the change contents passing the verification;
and executing the change content passing the verification according to the change execution strategy so as to complete the database change.
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.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that 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, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application 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 above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (13)

1. A database change method performed by a database change platform server, wherein the method comprises:
receiving a database change request, wherein the database change request comprises change content;
verifying the change content to obtain the change content passing verification, wherein the verification comprises performability verification and quality verification;
verifying the change contents passing the verification according to a change verification strategy to obtain the change contents passing the verification;
and executing the change content passing the verification according to the change execution strategy so as to complete the database change.
2. The method of claim 1, wherein the verifying the changed content, and obtaining the verified changed content comprises:
performing performability verification on the change content by utilizing an inclusion automation operation and maintenance tool;
under the condition that the changed content is executable, performing quality check on the changed content to obtain the changed content passing the quality check according to a quality check result;
and under the condition that the changed content is not executable, directly optimizing the changed content by using an SQL optimization tool to obtain the changed content passing the verification.
3. The method of claim 2, wherein the quality checking the modified content to obtain the verified modified content according to the quality checking result comprises:
performing quality check on the changed content by using an SQL optimization tool, wherein the quality check comprises one or more of a Where condition, an aggregation condition, a multi-table connection relation and a multi-column index, and obtaining a quality check result;
when the quality inspection result is that the quality inspection is passed, directly taking the change content as the change content passed by the quality inspection;
and outputting an SQL statement optimization suggestion under the condition that the quality inspection result is that the quality inspection fails, so as to obtain the change content passing the inspection according to the SQL statement optimization suggestion.
4. The method of claim 1, wherein the modified content comprises modified SQL, and the verifying the modified content comprises:
determining a change type for changing the SQL by using the Druid database connection pool component;
and checking the changed SQL according to the change type of the changed SQL to obtain the changed SQL which passes the check.
5. The method of claim 4, wherein the change type of the change SQL comprises a DML type, and after the change content is checked to obtain the checked change content, the method further comprises:
and under the condition that the verification fails, generating a rollback statement according to the change SQL of the DML type.
6. The method of claim 1, wherein after verifying the modified content to obtain verified modified content, the method further comprises:
generating a change order according to the change content so as to complete database change by executing the change order;
the change list comprises N change contents corresponding to M data sources, N and M are integers, and N is not less than M.
7. The method of claim 1, wherein the change auditing policy includes a change auditing process, and the auditing the change content according to the change auditing policy includes:
determining a change type and a change auditing process corresponding to the change type according to the database change request;
and triggering the change auditing process so that an auditing platform audits the changed content according to the change auditing process.
8. The method of claim 1, wherein the executing the audited changed content according to the change execution policy comprises:
determining a target execution strategy according to the database change request;
and under the condition that the target execution strategy is an automatic execution strategy, automatically executing the changed contents which are passed by the examination according to a preset execution time interval.
9. The method of claim 1, wherein after executing the audited changed content according to a change execution policy, the method further comprises:
acquiring an execution result of the changed content;
generating a database change record according to the execution result of the change content, wherein the database change record comprises one or more of audit information, execution information, change time, change influence and operators of the change content;
and performing statistical analysis on the database change records, and generating a database change report according to the statistical analysis result.
10. The method of claim 1, wherein the method further comprises:
providing a front-end page;
the receiving a database change request comprises:
and receiving the database change request through the front-end page.
11. A database change device applied to a database change platform server, wherein the device is used for implementing the method of any one of claims 1 to 10.
12. An electronic device, comprising:
a processor; and
a memory arranged to store computer executable instructions which, when executed, cause the processor to perform the method of any one of claims 1 to 10.
13. A computer readable storage medium storing one or more programs which, when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method of any of claims 1-10.
CN202110880428.XA 2021-08-02 2021-08-02 Database changing method and device, electronic equipment and storage medium Pending CN115701599A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110880428.XA CN115701599A (en) 2021-08-02 2021-08-02 Database changing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110880428.XA CN115701599A (en) 2021-08-02 2021-08-02 Database changing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115701599A true CN115701599A (en) 2023-02-10

Family

ID=85142397

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110880428.XA Pending CN115701599A (en) 2021-08-02 2021-08-02 Database changing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115701599A (en)

Similar Documents

Publication Publication Date Title
KR102033971B1 (en) Data quality analysis
US10013439B2 (en) Automatic generation of instantiation rules to determine quality of data migration
CN110543483A (en) Data auditing method and device and electronic equipment
US8832125B2 (en) Extensible event-driven log analysis framework
US20140109053A1 (en) Identifying high impact bugs
KR20170083569A (en) Processing queries containing a union-type operation
CN107766353B (en) Method and device for migrating statistical information of database
US20160132368A1 (en) Event processing development environment
CN107153609B (en) Automatic testing method and device
US20200089792A1 (en) Consistency checks between database systems
CN110674161A (en) Method, system, storage medium and SQL operation platform for online SQL
CN112579578A (en) Metadata-based data quality management method, device and system and server
WO2019214014A1 (en) Online product management method and apparatus, terminal device, and storage medium
CN112861491A (en) Report processing method and device, electronic equipment and computer readable storage medium
CN115701599A (en) Database changing method and device, electronic equipment and storage medium
CN115757174A (en) Database difference detection method and device
US11740995B2 (en) Source quality check service
CN115357594A (en) Block chain-based data model updating method and related equipment
US11720553B2 (en) Schema with methods specifying data rules, and method of use
US8856166B2 (en) Query validator
CN110688144B (en) Method and device for optimizing service interface configuration and electronic equipment
CN115826928B (en) Program generating method, system, electronic device and computer readable storage medium
US11831490B1 (en) Systems, methods, and media for performing information technology service management correlation for infrastructure environment functions
CN115576959B (en) Real-time quality inspection method and device, electronic equipment and storage medium
CN117331926B (en) Data auditing method and device, electronic equipment and storage medium

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