Database sql incremental change statement automatic generation and maintenance method

Through the automatic generation and maintenance method of database SQL incremental change statements, the problem of difficult to locate and deal with database table schema changes is solved, and the automatic recording and execution of schema changes is realized, which simplifies the database deployment process.

CN119415530APending Publication Date: 2025-02-11SUZHOU COLLABORATIVE INNOVATION INTELLIGENT MFG EQUIP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411429756.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

When the schema changes of database tables, it is difficult for the prior art to effectively locate and process schema changes of all data tables since the last deployment, resulting in complex database deployment process and easy data loss.

Method used

Using the database SQL incremental change statement automatic generation and maintenance method, by introducing the database script incremental recording tool, it will automatically convert the schema change statement of alter table or drop table when the data table schema changes, and record it in the incremental SQL file, marked Change timestamp.

Benefits of technology

Simplifies the maintenance of database scripts, automatically records and executes schema change statements, avoids manual search and positioning changes, and simplifies the database deployment process without deleting existing data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415530A_ABST
    Figure CN119415530A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of database maintenance, and discloses a database sql incremental change statement automatic generation and maintenance method which comprises the following steps: S1, first deployment: performing first deployment when a database script of a service system needs to be maintained and updated, and creating a database table by adopting the database script, adding service data in subsequent use; s2, second deployment: after the service data is added, the database script is updated for multiple times; and S3, changing and converting. When the database is deployed, the incremental sql script after the last deployment is called for execution according to the last deployment date, existing data does not need to be deleted, database script changes do not need to be searched and positioned, database tables do not need to be manually modified one by one according to the database script changes, and the database deployment work is effectively simplified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database maintenance, and in particular to a method for automatically generating and maintaining database SQL incremental change statements. Background Art

[0002] Currently, in the development and maintenance of business systems, developers need to continuously maintain and update database scripts. At the same time, the system faces the problem of how to upgrade the database during multiple deployments.

[0003] Generally, database script v1.1 is used to create database tables in the first deployment, and a lot of business data has been added in subsequent use. In the second deployment, the database script has been updated a lot. Therefore, in the new deployment, these schema changes must be reflected in the database, because the application and the data table are matched. If the database table is not updated, the system may run incorrectly. However, a lot of business data has been accumulated in the current database table, which makes it impossible to delete the data table and then re-run the full database script. This will delete the original business data. If you choose not to delete the data and manually update the schema of the data table, the database script is a full script, and it is difficult to locate the schema changes of all data tables since the last deployment. Therefore, a database sql incremental change statement automatic generation and maintenance method is proposed. Summary of the invention

[0004] 1. Technical issues to be resolved

[0005] In view of the shortcomings of the prior art, the present invention provides a method for automatically generating and maintaining database sql incremental change statements, which can delete the original business data when updating the database table system. If you choose not to delete the data and manually update the schema of the data table, you will face the problem that the database script is a full script and it is difficult to locate the schema changes of all data tables since the last deployment.

[0006] (II) Technical solution

[0007] To achieve the above object, the present invention provides the following technical solutions:

[0008] A method for automatically generating and maintaining a database SQL incremental change statement comprises the following steps:

[0009] S1: The first deployment is performed when the database script of the business system needs to be maintained and updated. The database table is created using the database script, and business data is added in subsequent use.

[0010] S2: The second deployment, after adding business data, the database script has been updated several times;

[0011] S3: Change conversion: Introducing a database script incremental recording tool, which is responsible for automatically converting table changes into schema change statements such as alter table and drop table when the table schema is changed, recording them in an incremental SQL file, and marking the timestamp of the change;

[0012] S4: Database maintenance. When a new database deployment is required, all incremental SQL statements from the last database deployment date to the current time interval are retrieved and executed in the last deployed database environment to upgrade and update the database.

[0013] As a further solution of the present invention, the S1 includes a database table creation module, and the database table creation module is deployed after being created.

[0014] Furthermore, the multiple updates in S2 have changed the schema of multiple data tables.

[0015] On the basis of the above scheme, S3 includes a data table change conversion module, and the data table change conversion module is connected to a storage module, and the storage module automatically records and stores when the data table structure changes.

[0016] Furthermore, S4 includes a deployment module, and the deployment module includes a timing module, the timing module provides the time of the last database deployment, the tool automatically compares the time, and the deployment module automatically executes all incremental SQL statements within the time interval from the last deployment time to the current time.

[0017] (III) Beneficial effects

[0018] Compared with the prior art, the present invention provides a method for automatically generating and maintaining database SQL incremental change statements, which has the following beneficial effects:

[0019] 1. The present invention effectively simplifies the maintenance work of database scripts. When developers modify the schema of a data table, the changes are automatically translated into schema change statements and stored together with the change date in a specific incremental SQL file.

[0020] 2. When deploying a database, the present invention retrieves the incremental SQL script since the last deployment according to the last deployment date for execution, without deleting existing data, searching and locating database script changes, and manually modifying database tables one by one, thereby effectively simplifying the database deployment work. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 The present invention provides a flowchart of the steps of a method for automatically generating and maintaining database SQL incremental change statements. DETAILED DESCRIPTION

[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] Example 1

[0024] Reference Figure 1 A method for automatically generating and maintaining a database SQL incremental change statement comprises the following steps:

[0025] S1: The first deployment is performed when the database script of the business system needs to be maintained and updated. The database table is created using the database script v1.1, and a lot of business data has been added in subsequent use. S1 includes a database table creation module, which is deployed after the database table creation module is created;

[0026] S2: The second deployment. After adding business data, the database script v1.1 has been updated to v1.2 several times. S2 has been updated to multiple data tables and schema changes have been made.

[0027] S3: Change conversion, which introduces a database script incremental recording tool. It is responsible for automatically converting data table changes into schema change statements such as alter table and drop table when the data table schema is changed, recording them in an incremental SQL file, and marking the timestamp of the change, effectively simplifying the maintenance of database scripts. When developers modify the schema of a data table, the changes are automatically translated into schema change statements and stored in a specific incremental SQL file together with the change date. S3 includes a data table change conversion module, and the data table change conversion module is connected to a storage module. The storage module automatically records and stores changes in the data table structure;

[0028] S4: Database maintenance. When a new database deployment is required, all incremental SQL statements from the last database deployment date to the current time interval are retrieved and executed in the last deployed database environment to upgrade and update the database. When the database is deployed, the incremental SQL scripts since the last deployment are retrieved and executed according to the last deployment date. There is no need to delete existing data, find and locate database script changes, and manually modify database tables one by one based on this. This effectively simplifies the database deployment work. S4 includes a deployment module, and the deployment module includes a timing module. The timing module provides the last database deployment time, and the tool automatically compares the time. The deployment module automatically executes all incremental SQL statements from the last deployment time to the current time interval.

[0029] Example 2

[0030] Reference Figure 1 A method for automatically generating and maintaining a database SQL incremental change statement comprises the following steps:

[0031] S1: The first deployment is performed when the database script of the business system needs to be maintained and updated. The database table is created using the database script, and a lot of business data has been added in subsequent use;

[0032] S2: The second deployment, after adding business data, the database script made multiple schema changes;

[0033] S3: Change conversion: introduces a database script incremental recording tool to automatically convert table changes into schema change statements such as alter table or drop table when the table schema is changed, record the changes in an incremental SQL file, and mark the timestamp of the changes, effectively simplifying the maintenance of database scripts. When developers modify the schema of a table, the changes are automatically translated into schema change statements and stored in a specific incremental SQL file together with the change date.

[0034] S4: Database maintenance. When a new database deployment is required, all incremental SQL statements from the last database deployment date to the current time period are retrieved and executed in the last deployed database environment to upgrade and update the database. When deploying the database, the incremental SQL scripts since the last deployment are retrieved and executed according to the last deployment date. There is no need to delete existing data, find and locate database script changes, and manually modify database tables one by one, which effectively simplifies database deployment work.

[0035] In the description of this article, it should be noted that relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0036] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for automatically generating and maintaining database sql incremental change statements, characterized in that: The following steps are involved: S1: The first deployment is performed when the database script of the business system needs to be maintained and updated. The database table is created using the database script, and business data is added in subsequent use. S2: The second deployment, after adding business data, the database script has been updated several times; S3: Change conversion: Introducing a database script incremental recording tool, which is responsible for automatically converting table changes into schema change statements such as alter table and drop table when the table schema is changed, recording them in an incremental SQL file, and marking the timestamp of the change; S4: Database maintenance. When a new database deployment is required, all incremental SQL statements from the last database deployment date to the current time interval are retrieved and executed in the last deployed database environment to upgrade and update the database.

2. A method for automatically generating and maintaining database sql incremental change statements according to claim 1, characterized in that: The S1 includes a database table creation module, which is deployed after being created.

3. A method for automatically generating and maintaining database sql incremental change statements according to claim 2, characterized in that: The multiple updates in S2 have changed the schema of multiple data tables.

4. A method for automatically generating and maintaining database sql incremental change statements according to claim 1, characterized in that: The S3 includes a data table change conversion module, and the data table change conversion module is connected to a storage module, and the storage module automatically records and stores when the data table structure changes.

5. A method for automatically generating and maintaining database sql incremental change statements according to claim 4, characterized in that: The S4 includes a deployment module, and the deployment module includes a timing module. The timing module provides the time of the last database deployment. The tool automatically compares the time. The deployment module automatically executes all incremental SQL statements within the time interval from the last deployment time to the current time.