A database change management method, device, equipment and storage medium

CN122925341APending Publication Date: 2026-10-16HUA XIA BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611118650.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-27
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0003]然而,当前以Flyway为代表的数据库版本控制与迁移工具,在应对金融企业多数据库和多环境的复杂变更场景时存在明显不足

Benefits of technology

从上述技术方案可知,本申请提供的一种数据库变更管控方法、装置、设备及存储介质,所述方法包括:首先,获取SQL脚本物料包,并对SQL脚本物料包进行打包处理,得到可执行程序包,其中,可执行程序包中包括多个数据库变更指令的SQL脚本。接着,接收用于启动可执行程序包的命令参数,并获取与命令参数对应的配置信息,配置信息中包含数据库连接信息。随后,解析命令参数和配置信息,确定目标数据库清单,目标数据库清单中包括多个目标数据库。最后,并行发起对目标数据库清单中多个目标数据库的变更任务,针对每个目标数据库,串行执行可执行程序包中的各SQL脚本,以实现对目标数据库的变更。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122925341A_ABST
    Figure CN122925341A_ABST
Patent Text Reader

Abstract

The application discloses a database change management method and device, equipment and storage medium, the method comprises: obtaining a SQL script material package; the SQL script material package is packed and handled, and an executable program package is obtained, the executable program package includes the SQL script of multiple database change instructions; receive the command parameter for starting the executable program package, and obtain the configuration information corresponding to the command parameter, and the configuration information contains database connection information; the command parameter and configuration information are parsed, the target database list is determined, and the target database list includes multiple target databases; the change task of multiple target databases in the target database list is initiated in parallel, and for each target database, each SQL script in the executable program package is executed in series to realize the change of the target database. In this way, by initiating the change task in parallel for multiple target databases, the change efficiency of the target database is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a database change management method, apparatus, device, and storage medium. Background Technology

[0002] As financial enterprises continue to deepen their digital transformation, the iteration pace of core business systems continues to accelerate. As the cornerstone of carrying core financial data, the database's schema and the standardization, security, and efficiency of data changes are directly related to the stable operation of the system and data consistency.

[0003] However, current database version control and migration tools, such as Flyway, have significant shortcomings in handling complex change scenarios involving multiple databases and environments in financial enterprises. On one hand, sensitive information such as database connection passwords and business parameters are scattered across configuration files or SQL scripts in various environments, increasing configuration management complexity and posing security risks of information leakage. On the other hand, existing tools only support executing change scripts serially on a single data source. When multiple databases are involved, the overall release window is significantly lengthened, failing to meet the needs of rapid business delivery. Summary of the Invention

[0004] This application provides a database change management method, apparatus, device, and storage medium. It eliminates the need to pre-write database connection information into scripts, instead dynamically obtaining it through command parameters. This avoids the management complexity and leakage risks associated with repeatedly maintaining database connection information across multiple environment configurations. Furthermore, by initiating change tasks on multiple target databases in parallel, it effectively improves the efficiency of target database changes.

[0005] In a first aspect, embodiments of this application provide a database change management method, the method comprising: Retrieve the SQL script material package; The SQL script material package is packaged to obtain an executable program package, which includes multiple SQL scripts for database change instructions; Receive command parameters for starting the executable package, and obtain configuration information corresponding to the command parameters, the configuration information including database connection information; The command parameters and configuration information are parsed to determine a list of target databases, which includes multiple target databases; Initiate change tasks for multiple target databases in the target database list in parallel. For each target database, execute each SQL script in the executable package serially to achieve the change of the target database.

[0006] One feasible implementation method, wherein packaging the SQL script material package to obtain an executable program package, includes: Based on preset verification rules, the SQL script in the SQL script material package is verified to obtain the verification result; If the verification result passes, the SQL script material package is packaged to obtain an executable program package.

[0007] In one feasible implementation, the configuration information further includes replacement values ​​corresponding to placeholders; For each target database, the SQL scripts in the executable package are executed sequentially, including: For each target database, each of the SQL scripts in the executable package is executed serially, and the placeholders in each of the SQL scripts in the executable package are replaced with corresponding replacement values.

[0008] One feasible implementation of the method further includes: If any SQL script within the executable package fails to execute and that SQL script is a data content manipulation script, roll back the changes made by that SQL script to the target database so that the target database is restored to its state before the SQL script was executed.

[0009] One feasible implementation of the method further includes: When a rollback instruction is received and any SQL script in the executable package is a data structure change script, the rollback script pre-placed in the executable package is executed to restore the target database to its state before the executable package was executed.

[0010] One feasible implementation of the method further includes: If the verification result fails, the packaging process of the SQL script material package is blocked and the verification error message is output.

[0011] One feasible implementation method is that the preset verification rules include path and naming convention verification, content and semantic verification, and version consistency verification. The path and naming convention verification is used to verify the standardization of the storage path and file naming of the SQL script; The content and semantic verification is used to verify the syntactic correctness and semantic rationality of the SQL statements in the SQL script; The version consistency check is used to verify the consistency between the version number of the SQL script and the version number of the directory where it is located.

[0012] Secondly, embodiments of this application provide a database change management device, including: The material package acquisition module is used to acquire material packages from SQL scripts. The material package packaging module is used to package the SQL script material package to obtain an executable program package, which includes multiple SQL scripts for database change instructions. The command receiving module is used to receive command parameters for starting the executable program package and obtain configuration information corresponding to the command parameters, wherein the configuration information includes database connection information; The list determination module is used to parse the command parameters and the configuration information to determine the target database list, which includes multiple target databases; The script execution module is used to execute each of the SQL scripts in the executable package in parallel for the multiple target databases in the target database list to complete the modification of the target databases, wherein each of the SQL scripts in each target database is executed sequentially.

[0013] Thirdly, embodiments of this application provide an electronic device, the device including: a processor, a memory, and a system bus; The processor and the memory are connected via the system bus; The memory is used to store a program, which includes instructions that, when executed by the processor, cause the processor to perform any of the implementation steps of the database change control method described above.

[0014] Fourthly, embodiments of this application provide a computer-readable storage medium for storing a computer program, which, when executed by a terminal device, implements any of the implementation steps of the database change control method described above.

[0015] As can be seen from the above technical solutions, the embodiments of this application have the following advantages: As can be seen from the above technical solution, this application provides a database change management method, apparatus, device, and storage medium. The method includes: First, obtaining an SQL script material package and packaging the SQL script material package to obtain an executable program package, wherein the executable program package includes multiple SQL scripts for database change instructions. Next, receiving command parameters for starting the executable program package and obtaining configuration information corresponding to the command parameters, the configuration information including database connection information. Subsequently, parsing the command parameters and configuration information to determine a target database list, the target database list including multiple target databases. Finally, initiating change tasks for multiple target databases in the target database list in parallel, and for each target database, executing each SQL script in the executable program package serially to achieve the change of the target database.

[0016] As can be seen, this application packages SQL script materials into an executable program package, which includes SQL scripts for multiple database change instructions. Based on this, it receives command parameters to start the executable program package and obtains the configuration information corresponding to these command parameters, including database connection information. Thus, the SQL scripts and configuration information are physically separated. Database connection information no longer needs to be pre-written into the configuration but is dynamically obtained through command parameters, thereby avoiding the management complexity and leakage risks caused by repeatedly maintaining database connection information in multiple environment scripts. Subsequently, by parsing the command parameters and configuration information, multiple target databases involved in this change are identified, forming a target database list. Finally, change tasks are initiated in parallel for multiple target databases in this target database list, so that the change tasks for each target database no longer queue sequentially, significantly shortening the overall release time in multi-database scenarios. Simultaneously, for each target database, each SQL script in the executable program package is executed serially, ensuring that the execution order and dependencies of change instructions within the same target database are not disrupted, avoiding data inconsistency issues that may arise from concurrent execution. Therefore, this application effectively overcomes the problem of low execution efficiency in the prior art under decentralized configuration management and multi-database scenarios. Attached Figure Description

[0017] Figure 1 A flowchart illustrating a database change control method provided in this application embodiment; Figure 2 This application provides a schematic diagram of a material package verification and packaging process. Figure 3 A flowchart illustrating the overall framework of a database change control method provided in this application embodiment; Figure 4 This is a schematic diagram of a database change management device provided in an embodiment of this application. Detailed Implementation

[0018] As mentioned earlier, current database version control and migration tools, such as Flyway, have significant shortcomings in handling complex change scenarios involving multiple databases and environments in financial enterprises. On one hand, sensitive information such as database connection passwords and business parameters are scattered across configuration files or SQL scripts in various environments, increasing configuration management complexity and posing security risks of information leakage. On the other hand, existing tools only support executing change scripts serially on a single data source. When multiple databases are involved, the overall release window is significantly lengthened, failing to meet the needs of rapid business delivery.

[0019] To address the aforementioned problems, this application provides a database change management method, apparatus, device, and storage medium. The method includes: First, obtaining an SQL script material package and packaging it to obtain an executable package, wherein the executable package includes multiple SQL scripts containing database change instructions. Next, receiving command parameters for starting the executable package and obtaining configuration information corresponding to the command parameters, including database connection information. Then, parsing the command parameters and configuration information to determine a target database list, which includes multiple target databases. Finally, initiating change tasks for multiple target databases in the target database list in parallel, and sequentially executing each SQL script in the executable package for each target database to achieve the change of the target database.

[0020] As can be seen, this application packages SQL script materials into an executable program package, which includes SQL scripts for multiple database change instructions. Based on this, it receives command parameters to start the executable program package and obtains the configuration information corresponding to these command parameters, including database connection information. Thus, the SQL scripts and configuration information are physically separated. Database connection information no longer needs to be pre-written into the configuration but is dynamically obtained through command parameters, thereby avoiding the management complexity and leakage risks caused by repeatedly maintaining database connection information in multiple environment scripts. Subsequently, by parsing the command parameters and configuration information, multiple target databases involved in this change are identified, forming a target database list. Finally, change tasks are initiated in parallel for multiple target databases in this target database list, so that the change tasks for each target database no longer queue sequentially, significantly shortening the overall release time in multi-database scenarios. Simultaneously, for each target database, each SQL script in the executable program package is executed serially, ensuring that the execution order and dependencies of change instructions within the same target database are not disrupted, avoiding data inconsistency issues that may arise from concurrent execution. Therefore, this application effectively overcomes the problem of low execution efficiency in the prior art under decentralized configuration management and multi-database scenarios.

[0021] It should be noted that the embodiments of this application do not limit the executing entity of the database change control method. For example, the database change control method of this application embodiment can be applied to information processing devices such as servers or terminal devices. The server can be a standalone server, a cluster server, or a cloud server. The terminal device can be an electronic device such as a smartphone, computer, personal digital assistant (PDA), or tablet computer.

[0022] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0023] Figure 1 This is a flowchart illustrating a database change control method provided in an embodiment of this application. (In conjunction with...) Figure 1 As shown, it may include steps S101-S105.

[0024] S101: Obtain the SQL script material package.

[0025] In this embodiment of the application, an SQL script material package refers to a collection of SQL script files organized according to a predetermined specification, containing all the operation instructions required for database changes. Specifically, the SQL script material package includes multiple SQL script files, each containing database change instructions, such as data content operation scripts (e.g., DML statements like INSERT, UPDATE, DELETE) and data structure change scripts (e.g., DDL statements like CREATE TABLE, ALTER TABLE).

[0026] Optionally, the SQL script material package may also include a local configuration file and an SQL publishing tool SDK (Software Development Kit). The local configuration file is used to record basic information about the material package, and the SQL publishing tool SDK provides the underlying support code required for SQL script execution.

[0027] In one possible implementation, the SQL script material package is organized according to a preset directory structure. Each SQL script file is stored in its corresponding directory path, and the file names follow preset version naming rules, with the version number in the file name matching the version number of the directory it belongs to. This unified directory structure and naming convention provides a foundation for subsequent automated verification and packaging processes.

[0028] In another possible implementation, embodiments of this application may obtain a specified version of the SQL script material package from a version control system (such as Git or SVN); or, read a pre-maintained SQL script material package from a local storage path; or, receive an SQL script material package uploaded by a user. Embodiments of this application do not limit the specific method of obtaining the material package.

[0029] In practice, developers complete the writing and maintenance of SQL scripts for each component in the local material package maintenance project to obtain the SQL script material package. The material package maintenance project is used for unified management of the SQL material packages, including creation, approval, and version control.

[0030] By obtaining the SQL script material package, a standardized input source is provided for subsequent verification, packaging, and automated release, enabling the entire database change control process to have a unified starting point and traceability.

[0031] S102: Package the SQL script material package to obtain an executable package, which includes SQL scripts containing multiple database change instructions.

[0032] In this embodiment of the application, after obtaining the SQL script material package, it is necessary to package the SQL script material package to obtain an executable program package that can run independently.

[0033] Figure 2 This application provides a schematic diagram of a material package verification and packaging process, combined with... Figure 2 As can be seen, the operations and maintenance personnel maintain SQL scripts in the material package maintenance project and execute packaging commands on the SQL script material packages. After receiving the packaging command, the material package maintenance project triggers automated verification. If the verification passes, the material package maintenance project generates an executable package; if the verification fails, the material package maintenance project returns an error message to the operations and maintenance personnel, blocking the packaging process. In the above process, automated verification acts as a quality gate before packaging, intercepting quality issues with the SQL scripts before release, ensuring that all SQL scripts entering the executable package pass verification, thereby improving the security and reliability of database changes.

[0034] Specifically, before packaging the SQL script material package, an automated verification plugin is triggered to perform a pre-check on the SQL script material package. This automated verification plugin is integrated into the project build tool's plugin framework. Based on preset verification rules, it verifies each SQL script in the SQL script material package to obtain the verification result, which serves as the quality gate for the SQL script material package to enter the packaging process. The automated verification plugin adopts a pluggable modular design, allowing different verification rules to be dynamically loaded or unloaded according to actual needs, providing good scalability and reusability. The preset verification rules include path and naming convention verification, content and semantic verification, and version consistency verification.

[0035] Specifically, path and naming convention verification checks the storage path and file naming conventions of SQL scripts, ensuring that each SQL script is stored in the correct directory path and that the filenames match the preset version naming rules. Content and semantic verification checks the syntactic correctness and semantic rationality of SQL statements within the SQL scripts. This application can read the SQL file content through an integrated SQL parser, perform syntax checks and semantic analysis, and check whether the SQL statements meet the database characteristic requirements. Version consistency verification checks the consistency between the version number of the SQL script and the version number of its directory, ensuring that the version number in the filename matches the version number of the directory where the file is located.

[0036] If the verification result passes, the packaging command is executed using a project build tool (such as Maven or Gradle) to compile and package the SQL script files in the SQL script material package together with the SQL publishing tool SDK, generating a standalone executable package. This executable package includes SQL scripts for multiple database change instructions. The compilation and packaging process involves compiling the source code of the SQL publishing tool SDK into bytecode files, archiving the SQL script files as resource files, and configuring the program entry class, thereby generating an executable package that can be directly started via the command line.

[0037] It should be noted that the executable package in this application embodiment can be in JAR (Java Archive) package format, and the database change release process can be started by executing the JAR package.

[0038] Optionally, the executable package in this application embodiment not only includes each SQL script file in the SQL script material package, but also includes executable code of SQL execution logic, specifically including executable code of configuration parameter parser, multi-database parallel scheduler and SQL execution controller, which are used to drive each target database to execute SQL scripts in subsequent steps.

[0039] If the validation fails, the packaging process for the SQL script material package will be blocked, and a validation error message will be output. The validation error message may include the name of the SQL script file that failed validation, the error type, the error location, and the error description to help developers quickly locate and fix the problem.

[0040] S103: Receive command parameters for starting the executable package and obtain configuration information corresponding to the command parameters. The configuration information includes database connection information.

[0041] In this embodiment, after obtaining the executable package, the user launches the executable package via a command, passing command parameters in the launch command. These command parameters are used to indicate the target environment or execution scope of this database change task, such as specifying whether the change is for a production environment or a test environment.

[0042] Specifically, after the executable package starts, its internal configuration parameter parser first receives the user-input startup command parameters. Simultaneously, the configuration parameter parser sends a request to the management and control center to obtain the configuration information corresponding to the command parameters. The management and control center is independently deployed and supports configuration management services to centrally store and manage various types of configuration information. Upon receiving the configuration request, the management and control center queries and returns the corresponding configuration information based on information such as the environment identifier carried in the command parameters. The configuration information includes database connection information, such as the database connection address, port, and instance name. After obtaining the configuration information, the executable package can determine the target database for this change based on the database connection information in the configuration information, preparing for subsequent parallel change tasks.

[0043] In one possible implementation, the configuration information is stored in encrypted form in the control center. When returning the configuration information, the control center decrypts it based on the requester's identity and permissions before sending it out, making sensitive information more secure during transmission. In another possible implementation, the configuration information also includes replacement values ​​for placeholders in the SQL scripts. Before executing each SQL script, the executable package replaces the placeholders in each SQL script according to the replacement values, allowing the same set of SQL scripts to use different parameter values ​​when executed in different environments.

[0044] In this embodiment, by storing sensitive configuration information such as database connection information and placeholder replacement values ​​uniformly in the management center, the executable package itself no longer contains any specific environment-related configurations, thus achieving physical separation between configuration information and the executable package. This avoids the risk of sensitive information being leaked when dispersed along with the package or script files, and allows the same executable package to be reused in different environments without needing to build a separate package for each environment.

[0045] S104: Parse command parameters and configuration information to determine the target database list, which includes multiple target databases.

[0046] In this embodiment of the application, after obtaining the configuration information, the configuration parameter parser parses the startup command parameters and the configuration information obtained from the management and control center to determine all target databases involved in this database change task and generate a target database list.

[0047] Specifically, the configuration information includes database connection information for multiple databases, such as the database connection address, port, and instance name for each environment (production, testing, and development). The configuration parameter parser first extracts the environment identifier from the startup command parameters, then uses this environment identifier as an index to search for database connection information matching that environment identifier in the configuration information, thereby identifying all databases in that environment and generating a target database list. The target database list includes multiple target databases, each corresponding to a database instance for which an SQL script needs to be executed.

[0048] In one possible implementation, the command parameters also include a change scope identifier. After determining the environment, the configuration parameter parser further searches the configuration information for databases belonging to that change scope based on the change scope identifier, thereby filtering the target database list. For example, when the change scope identifier is specified as "payment module," only databases related to the payment module in that environment are included in the target database list. Thus, users can flexibly control the scope of databases involved in this change through command parameters without modifying executable packages or configuration files.

[0049] In another possible implementation, the command parameters also include a concurrency parameter. The configuration parameter parser extracts the concurrency parameter from the command parameters to determine the number of threads controlling the parallel execution of the change task in subsequent steps. This application does not limit the specific value and format of the concurrency parameter.

[0050] In addition, the configuration information also includes the execution order information of the SQL scripts for each target database. The configuration parameter parser, while determining the list of target databases, also parses the execution order of the SQL scripts for each target database, providing a sequence basis for the subsequent sequential execution of each SQL script within each target database. Therefore, different target databases can independently execute the change scripts according to their respective configured execution order, without affecting each other.

[0051] This application embodiment generates a target database list by parsing command parameters and configuration information. On the one hand, it clarifies the scope of this change task and avoids performing change operations on irrelevant databases. On the other hand, it provides a clear database list for subsequent parallel execution of change tasks on multiple databases, making parallel changes have a clear target.

[0052] S105: Initiate change tasks for multiple target databases in the target database list in parallel. For each target database, execute each SQL script in the executable package serially to achieve the change of the target database.

[0053] In this embodiment of the application, after determining the list of target databases, the executable package initiates modification tasks for each target database in parallel according to the list, and realizes parallel scheduling of multiple target databases and serial execution within a single target database through a multi-database parallel scheduler, thereby efficiently completing the database modification.

[0054] Specifically, the multi-database parallel scheduler first obtains a list of target databases, which includes multiple target databases. Then, the scheduler creates a thread pool based on this list, with the number of threads corresponding to the number of target databases. The scheduler iterates through the list, submitting the change task for each target database as an independent task to the thread pool. The thread pool allocates an independent thread to each target database, and each thread executes its corresponding change task in parallel. In other words, each target database is handled by an independent thread, and these threads execute in parallel without interference.

[0055] Within each thread, for the target database it is responsible for, a connection is first established with the target database based on the database connection information in the configuration settings. Then, it retrieves the SQL scripts from the executable package and executes them sequentially in a preset order, replacing placeholders in each SQL script with their corresponding replacement values. After each SQL script completes execution, its execution status information (e.g., success or failure) is recorded. Once all SQL scripts have finished executing, the connection to the target database is closed, and resources are released. Thus, within a single target database, each SQL script is executed strictly in sequence, ensuring the correctness of the change order and data consistency.

[0056] It should be noted that, in this embodiment of the application, during the process of managing the thread pool by the multi-database parallel scheduler, the execution results of each thread are stored in a result set. The multi-database parallel scheduler traverses this result set to obtain the execution status of the change task for each target database, thereby determining the overall execution status of this change task. After the change tasks for all target databases have been executed, the overall release result is reported to the control center.

[0057] In one possible implementation, during the execution of each SQL script, an independent thread asynchronously reports the execution status information of each SQL script to the management center, ensuring that the reporting operation does not block the main thread's publishing efficiency. This application does not limit the specific method or timing of the reporting.

[0058] Therefore, this embodiment of the application initiates change tasks for multiple target databases in parallel, enabling these change tasks to be executed simultaneously without queuing, thus significantly shortening the overall release time in multi-database scenarios. Simultaneously, by executing each SQL script serially within each target database, the execution order and dependencies of change instructions within the same database are preserved, avoiding data inconsistency issues that may arise from concurrent execution and improving the efficiency and reliability of database changes.

[0059] Furthermore, in this embodiment of the application, before executing each SQL script, the SQL execution controller in the executable package first determines the type of any SQL script within the executable package. If the SQL script is a data manipulation script (such as DML statements like INSERT, UPDATE, and DELETE), the SQL execution controller automatically starts a transaction on the connection to the target database and then executes the SQL script.

[0060] If the SQL script executes successfully, the transaction is committed, and the changes take effect. If the SQL script fails, the current transaction is automatically rolled back, undoing the SQL script's changes to the target database and restoring the target database to its state before the SQL script was executed. Therefore, for data manipulation scripts that support transactions, automatic rollback is achieved through the database's own transaction mechanism when a single script fails to execute.

[0061] If the SQL script is a data structure modification script (such as DDL statements like CREATE TABLE or ALTER TABLE), the SQL execution controller cannot automatically undo it through transaction mechanisms because the target database typically does not support transaction rollback for DDL statements. Therefore, the SQL execution controller stops execution after recording its execution status, and this record can be used as a reference for subsequent rollback.

[0062] When a rollback command is received from a user and any SQL script in the executable package is a data structure change script, the pre-placed rollback script in the executable package is executed to restore the target database to its state before the executable package was executed. The rollback script is a pre-written script used to undo changes made to the target database and is included in the executable package before execution. When a rollback is needed, the executable package automatically executes the corresponding rollback script based on the rollback command and the recorded script execution status, thereby restoring the target database to its state before the change.

[0063] It should be noted that the rollback script mechanism provided in this application is not limited to data structure change scripts, but also applies to data content operation scripts. That is, for data content operation scripts, automatic undoing can be achieved through transaction rollback using the aforementioned first-level rollback mechanism, or undoing can be achieved through a rollback script pre-installed in the executable package according to actual needs.

[0064] Through the above rollback operation, this application achieves a two-layer security guarantee for target database change operations, effectively solving the problems of complex and risky rollback caused by DML scripts relying on manual transaction control and DDL scripts not supporting transaction rollback, and ensuring the consistency and controllability of database changes.

[0065] Based on the steps S101-S105 above, this application provides a database change management method, apparatus, device, and storage medium. The method includes: First, obtaining an SQL script material package and packaging the SQL script material package to obtain an executable program package, wherein the executable program package includes multiple SQL scripts for database change instructions. Next, receiving command parameters for starting the executable program package and obtaining configuration information corresponding to the command parameters, the configuration information including database connection information. Subsequently, parsing the command parameters and configuration information to determine a target database list, the target database list including multiple target databases. Finally, initiating change tasks for multiple target databases in the target database list in parallel, and for each target database, executing each SQL script in the executable program package serially to achieve the change of the target database. It can be seen that this application packages an SQL script material package into an executable program package, which includes multiple SQL scripts for database change instructions. Based on this, receiving command parameters for starting the executable program package and obtaining configuration information corresponding to the command parameters, the configuration information including database connection information. Therefore, the SQL scripts and configuration information are physically separated. Database connection information no longer needs to be pre-written into the configuration but is dynamically obtained through command parameters, thus avoiding the management complexity and leakage risks caused by repeated maintenance of database connection scripts. Subsequently, by parsing the command parameters and configuration information, multiple target databases involved in this change are identified, forming a target database list. Finally, change tasks are initiated in parallel for multiple target databases in this list, so that the change tasks for each target database no longer queue up sequentially, significantly shortening the overall release time in multi-database scenarios. At the same time, for each target database, each SQL script in the executable package is executed serially, ensuring that the execution order and dependencies of change instructions within the same target database are not disrupted, avoiding data inconsistency issues that may be caused by concurrent execution. Thus, this application effectively overcomes the problems of decentralized configuration management and low execution efficiency in multi-database scenarios in existing technologies.

[0066] Furthermore, Figure 3 This application provides an overall framework flowchart for a database change control method, combined with... Figure 3It is understood that the SQL script files in the SQL script material package, along with the executable code of the configuration parameter parser, multi-database parallel scheduler, and SQL execution controller, are compiled and packaged together to obtain an executable program package. The publishing client internally includes a configuration parameter parser, a multi-database parallel scheduler, and an SQL execution controller, which are used to implement configuration parsing, parallel scheduling, and SQL script execution functions, respectively. The control center includes a configuration management module and a visualization monitoring module. The configuration management module is used to distribute configuration information to the publishing client, and the visualization monitoring module is used to receive execution status information reported by the publishing client.

[0067] In practice, operations and maintenance personnel start the executable package by inputting commands. The configuration parameter parser obtains configuration information from the control center and parses the command parameters and configuration information to determine the target database list. The multi-database parallel scheduler initiates change tasks for each target database in parallel according to the target database list. The SQL execution controller obtains each SQL script in the executable package and executes each SQL script serially for each target database to realize the change of the target database, and reports the execution status to the visualization monitoring module.

[0068] It should be noted that the visual monitoring module records release information from two dimensions: the overall release task and script execution details. During execution, the release client asynchronously reports the execution status information of each SQL script (including script name, execution result, target database, and execution duration) to the control center. After all tasks are completed, the overall execution result is reported. The control center stores the received information as a structured historical record. Users can filter and view historical records and details from multiple dimensions such as environment, material package, batch, and status through the visual page, achieving traceability and auditability of the entire release chain.

[0069] Figure 4 This is a schematic diagram of a database change control device provided in an embodiment of this application. Figure 4 As shown, the database change management device 400 provided in this application embodiment may include: The material package acquisition module 401 is used to acquire material packages from SQL scripts. The material package packaging module 402 is used to package the SQL script material package to obtain an executable program package, wherein the executable program package includes multiple SQL scripts of database change instructions; The command receiving module 403 is used to receive command parameters for starting the executable program package and obtain configuration information corresponding to the command parameters, wherein the configuration information includes database connection information; The list determination module 404 is used to parse the command parameters and the configuration information to determine the target database list, which includes multiple target databases; The script execution module 405 is used to execute each of the SQL scripts in the executable package in parallel for the plurality of target databases in the target database list, so as to complete the modification of the target database, wherein each of the SQL scripts in each target database is executed sequentially.

[0070] Optionally, the material package packaging module 402 is specifically used for: Based on preset verification rules, the SQL script in the SQL script material package is verified to obtain the verification result; If the verification result passes, the SQL script material package is packaged to obtain an executable program package.

[0071] Optionally, the configuration information may also include replacement values ​​corresponding to placeholders; The script execution module 405 is specifically used for: For each target database, each of the SQL scripts in the executable package is executed serially, and the placeholders in each of the SQL scripts in the executable package are replaced with corresponding replacement values.

[0072] Optionally, the database change control device 400 may include: The first rollback module is used to roll back the changes made by any SQL script to the target database when the execution of any SQL script in the executable package fails and the SQL script is a data content operation script, so as to restore the target database to the state before the execution of the SQL script.

[0073] Optionally, the database change control device 400 may include: The second rollback module is used to execute a rollback script pre-placed in the executable package when a rollback instruction is received and any SQL script in the executable package is a data structure change script, so as to restore the target database to the state before the executable package was executed.

[0074] Optionally, the database change control device 400 may include: The error message output module is used to block the packaging process of the SQL script material package and output the verification error message when the verification result fails.

[0075] Optionally, the preset verification rules include path and naming convention verification, content and semantic verification, and version consistency verification; The path and naming convention verification is used to verify the standardization of the storage path and file naming of the SQL script; The content and semantic verification is used to verify the syntactic correctness and semantic rationality of the SQL statements in the SQL script; The version consistency check is used to verify the consistency between the version number of the SQL script and the version number of the directory where it is located.

[0076] Furthermore, embodiments of this application also provide an electronic device, including: a processor, a memory, and a system bus; The processor and the memory are connected via the system bus; The memory is used to store one or more programs, the one or more programs including instructions, which, when executed by the processor, cause the processor to perform any of the implementation steps of the database change control method described above.

[0077] Furthermore, embodiments of this application also provide a computer-readable storage medium for storing a computer program, which, when executed by a terminal device, implements any of the implementation steps of the database change control method described above.

[0078] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network communication device such as a media gateway, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application. It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on describing the differences from other embodiments. The same or similar parts between the various embodiments can be referred to mutually.

[0079] The system disclosed in the embodiments is described in a relatively simple manner because it corresponds to the method disclosed in the embodiments. For relevant details, please refer to the method section.

[0080] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0081] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A database change control method, characterized in that, The method comprises: acquiring a SQL script material package; performing packaging processing on the SQL script material package to obtain an executable program package, wherein the executable program package comprises a plurality of SQL scripts for database change instructions; receiving a command parameter for starting the executable program package, and acquiring configuration information corresponding to the command parameter, wherein the configuration information comprises database connection information; parsing the command parameter and the configuration information to determine a target database list, wherein the target database list comprises a plurality of target databases; initiating change tasks for the plurality of target databases in the target database list in parallel, and for each target database, serially executing each of the SQL scripts in the executable program package to implement a change to the target database.

2. The method according to claim 1, characterized in that, The performing packaging processing on the SQL script material package to obtain an executable program package comprises: verifying the SQL scripts in the SQL script material package based on a preset verification rule to obtain a verification result; when the verification result is passed, performing packaging processing on the SQL script material package to obtain the executable program package.

3. The method according to claim 1, characterized in that, The configuration information further comprises a replacement value corresponding to a placeholder; The serially executing each of the SQL scripts in the executable program package for each target database comprises: for each target database, serially executing each of the SQL scripts in the executable program package, and replacing placeholders in each of the SQL scripts in the executable program package with the corresponding replacement values.

4. The method according to claim 1, characterized in that, The method further comprises: when execution of any SQL script in the executable program package fails and the SQL script is a data content operation type script, rolling back the change of the target database made by the SQL script, so as to restore the target database to a state before the SQL script is executed.

5. The method according to claim 1, characterized in that, The method further comprises: when a rollback instruction is received and any SQL script in the executable program package is a data structure change type script, executing a rollback script pre-stored in the executable program package, so as to restore the target database to a state before the executable program package is executed.

6. The method according to claim 2, characterized in that, The method further comprises: when the verification result is not passed, blocking the packaging processing on the SQL script material package and outputting verification error information.

7. The method according to claim 2, characterized in that, The preset verification rules comprise path and naming specification verification, content and semantic verification, and version consistency verification; The path and naming specification verification is configured to verify the standardization of the storage path and file naming of the SQL script; The content and semantic verification is configured to verify the syntax correctness and semantic rationality of SQL statements in the SQL script; The version consistency verification is configured to verify the consistency between the version number of the SQL script and the version number of the directory where the SQL script is located.

8. A database change control device, characterized in that, comprises: a material package acquisition module, configured to acquire a SQL script material package; a material package packaging module, configured to perform packaging processing on the SQL script material package to obtain an executable program package, wherein the executable program package comprises a plurality of SQL scripts for database change instructions; The command receiving module is used to receive command parameters for starting the executable program package and obtain configuration information corresponding to the command parameters, wherein the configuration information includes database connection information; The list determination module is used to parse the command parameters and the configuration information to determine the target database list, which includes multiple target databases; The script execution module is used to execute each of the SQL scripts in the executable package in parallel for the multiple target databases in the target database list to complete the changes to the target databases, wherein each of the SQL scripts in each target database is executed sequentially.

9. An electronic device, characterized in that, The device includes: a processor, a memory, and a system bus; The processor and the memory are connected via the system bus; The memory is used to store a program, the program including instructions that, when executed by the processor, cause the processor to perform the steps of the database change control method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program, which, when executed by a terminal device, implements the steps of the database change control method according to any one of claims 1-7.