Database change method and device, electronic equipment and medium
By storing the database change content in a table file and automatically generating the change scripts with the script generation program, the problem of low database change deployment efficiency in the existing technology is solved, and efficient, accurate and reliable automatic database change is achieved.
Patent Information
- Application Number
- CN202411637573.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-03-07
AI Technical Summary
The existing database changes and deployment mostly relies on manual operation, which is low in efficiency and is difficult to meet efficient and flexible business needs.
By obtaining the database change content and storing it in a table file, and automatically generating the change script with the script generation program, the automatic change of the database is achieved.
Improve the efficiency and accuracy of database changes, reduce human errors, enhance the traceability and repeatability of changes, and ensure the consistency and reliability of changes.
Smart Images

Figure CN119576898A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to a database change method, device, electronic device and medium. Background Art
[0002] The database is the core component of the information system. In order to ensure that the database can efficiently and flexibly support increasingly complex and changing business scenarios and meet the requirements of real-time and accuracy of data processing, its table structure, stored procedures, indexes, fields and other elements need to be optimized and adjusted as business needs change and expand. This process is the change deployment of the database. However, the current change deployment of the database mostly relies on manual operations, which is inefficient. Summary of the invention
[0003] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0004] To this end, the first aspect of the present application is to propose a database change method.
[0005] The second aspect of the present application is to provide a database changing device.
[0006] A third aspect of the present application is to provide an electronic device.
[0007] A fourth aspect of the present application is to provide a non-transitory computer-readable storage medium.
[0008] A fifth aspect of the present application is to provide a computer program product.
[0009] To achieve the above-mentioned purpose, the first embodiment of the present application proposes a database modification method, including:
[0010] Acquire database change content, wherein the database change content is used to change at least one database, and the database change content corresponds to a target database object;
[0011] Obtaining a set table file, and storing the database change content in the table file, wherein the table file is used to store the attribute content of the database object;
[0012] For any of the databases, calling a target script generation program that matches the database type of the database and the target database object from the script generation program deployed in the table file, so as to generate a change script corresponding to the database based on the target script generation program;
[0013] According to the change script, a database change is performed on the corresponding database.
[0014] To achieve the above-mentioned purpose, the second embodiment of the present application proposes a database change device, including:
[0015] A first acquisition module is used to acquire database change content, wherein the database change content is used to change at least one database, and the database change content corresponds to a target database object;
[0016] A second acquisition module is used to acquire a set table file and store the database change content in the table file, wherein the table file is used to store the attribute content of the database object;
[0017] A script generation module, for calling, for any of the databases, a target script generation program that matches the database type of the database and the target database object from the script generation program deployed in the table file, so as to generate a change script corresponding to the database based on the target script generation program;
[0018] A change module is used to perform database changes on the corresponding database according to the change script.
[0019] To achieve the above-mentioned purpose, the third aspect of the present application provides an electronic device, including:
[0020] A processor, and a memory communicatively connected to the processor;
[0021] The memory stores computer-executable instructions;
[0022] The processor executes the computer-executable instructions stored in the memory to implement the database change method described in the first aspect.
[0023] In order to achieve the above-mentioned purpose, the fourth aspect of the present application proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the database change method described in the first aspect.
[0024] In order to achieve the above-mentioned purpose, the fifth aspect of the present application proposes a computer program product, including a computer program, which implements the database change method described in the first aspect when executed by a processor.
[0025] The present application obtains database change content, wherein the database change content is used to change at least one database, and the database change content corresponds to a target database object; obtains a set table file, and stores the database change content in the table file, wherein the table file is used to store the attribute content of the database object; for any database, from the script generation program deployed in the table file, calls the target script generation program that matches the database type and the target database object of the database, so as to generate a change script corresponding to the database based on the target script generation program; according to the change script, the database change is performed on the corresponding database. First, the table file provides a structured way to store the attribute content of the database object. Through the table file, the change details of each database object can be intuitively seen, which makes the database change content clearer and easier to manage; secondly, by combining the table file with the script generation program, the change script for a specific database type and database object can be automatically generated, thereby realizing the automatic change of the database, which not only improves the change efficiency, but also ensures the accuracy and consistency of the script, and reduces the errors introduced by human factors; finally, this combination method also enhances the traceability and repeatability of database changes, all changes are recorded in the table file, and any changes can be tracked and verified through the table file. In addition, since the change scripts corresponding to different databases can be automatically generated based on the table files, when changes need to be made to multiple databases, the same changes can be automatically executed in different databases at the same time, ensuring the consistency and reliability of the changes.
[0026] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0028] Figure 1 A flowchart of a database modification method provided in an embodiment of the present application;
[0029] Figure 2 A flowchart of another database modification method provided in an embodiment of the present application;
[0030] Figure 3 A flowchart of another database modification method provided in an embodiment of the present application;
[0031] Figure 4 A flowchart of another database modification method provided in an embodiment of the present application;
[0032] Figure 5 A schematic diagram of the structure of a database modification device provided in an embodiment of the present application;
[0033] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0035] It should be noted that the acquisition, transmission, storage, use, and processing of data (including but not limited to user device information, user personal information, etc.) in the technical solution of this application comply with the relevant provisions of relevant laws and regulations.
[0036] A database change method, device, electronic device, and medium according to an embodiment of the present application are described below with reference to the accompanying drawings.
[0037] Embodiment 1:
[0038] Figure 1 The following is a flow chart of a database modification method provided in an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0039] Step 101: Obtain database change content, wherein the database change content is used to change at least one database, and the database change content corresponds to a target database object.
[0040] In an embodiment of the present application, database change objects include data, table structures, views, fields, functions, packages, and stored procedures, etc. The target database object may refer to one or more of the aforementioned database change objects; the database change content is used to change the target database objects in one or more databases, and one or more databases may refer to one or more databases of the type Oracle database, TiDB database, and Greenplum (GP) database.
[0041] Step 102, obtaining a set table file, and storing the database change content in the table file, wherein the table file is used to store the attribute content of the database object.
[0042] In the embodiment of the present application, the set table file may include the database change content and the attribute content of the database object corresponding to each previous change. For example, for each change, the database change content, the attribute content of the database object before the change, and the attribute content of the database object after the change may be stored in association. The table file may refer to an EXCEL file.
[0043] In the embodiments of the present application, the attribute content of the database object refers to the specific details and characteristics of the database object that constitutes the database, and these attributes define the behavior, structure, and storage method of the database object. Taking the database object as a table structure as an example, the attribute content of the database object refers to the table name, the fields in the table, and the field attributes.
[0044] Step 103, for any database, call a target script generation program that matches the database type and target database object of the database from the script generation program deployed in the table file, so as to generate a change script corresponding to the database based on the target script generation program.
[0045] Since different types of databases may have different corresponding syntax structures, in order to realize automatic changes of different types of databases, script generation programs that match each database object under each database type can be deployed in the table file. For example, the table structure in database A corresponds to script generation program a, and the table structure in database B corresponds to script generation program b. It should be noted that the specific contents of script generation program a and script generation program b may be different due to differences in structure, syntax, etc. between database A and database B, but the overall execution logic and execution purpose of the program are the same.
[0046] In which, when the spreadsheet file is an EXCEL file, the script generation program may refer to a program written in VBS language in combination with macro technology.
[0047] For any database to be changed, according to the database type and the target database object, the target script generator is searched from the script generators deployed in the table file, and the corresponding change script is generated based on the target script generator.
[0048] Step 104: perform database changes on the corresponding database according to the change script.
[0049] In the embodiment of the present application, after obtaining the change script, the database is connected and the change script is executed to make database changes to the corresponding database.
[0050] In order to improve the success rate of database changes, as an example, after obtaining the change script, the change script can be tested in a test environment first, and after the test passes, the change script is executed to change the database.
[0051] The present application obtains database change content, wherein the database change content is used to change at least one database, and the database change content corresponds to a target database object; obtains a set table file, and stores the database change content in the table file, wherein the table file is used to store the attribute content of the database object; for any database, from the script generation program deployed in the table file, calls the target script generation program that matches the database type and the target database object of the database, so as to generate a change script corresponding to the database based on the target script generation program; according to the change script, the database change is performed on the corresponding database. First, the table file provides a structured way to store the attribute content of the database object. Through the table file, the change details of each database object can be intuitively seen, which makes the database change content clearer and easier to manage; secondly, by combining the table file with the script generation program, the change script for a specific database type and database object can be automatically generated, thereby realizing the automatic change of the database, which not only improves the change efficiency, but also ensures the accuracy and consistency of the script, and reduces the errors introduced by human factors; finally, this combination method also enhances the traceability and repeatability of database changes, all changes are recorded in the table file, and any changes can be tracked and verified through the table file. In addition, since the change scripts corresponding to different databases can be automatically generated based on the table files, when changes need to be made to multiple databases, the same changes can be automatically executed in different databases at the same time, ensuring the consistency and reliability of the changes.
[0052] Embodiment 2:
[0053] Figure 2 A flowchart of a database modification method provided in another embodiment of the present application is shown as follows: Figure 2 As shown, the method comprises the following steps:
[0054] Step 201, obtaining database change content.
[0055] Step 202, obtain the set table file, and store the database change content in the table file.
[0056] Step 203: Obtain a mapping table in the table file, where the mapping table is used to store a mapping relationship between a database type, a database object, and a script generation program identifier.
[0057] The table file includes multiple data tables, and the mapping table is one of the multiple data tables. For example, the data table may refer to a sheet. As an example, the mapping table is shown in the following table:
[0058]
[0059]
[0060] Step 204: for any database, according to the database type and the target database object of the database, search the mapping table for a matching target mapping relationship.
[0061] For any database, a mapping relationship between a database type corresponding to the database and a target database object can be searched in the mapping table, and the found mapping relationship is the target mapping relationship.
[0062] Step 205 , based on the script generator identifier in the target mapping relationship, call the target script generator from the script generators deployed in the table file.
[0063] There is a one-to-one correspondence between the script generation program identifier and the script generation program. Therefore, the target script generation program that matches the script generation program identifier can be called from the script generation program deployed in the table file.
[0064] The target script generation program is searched through the mapping relationship in the mapping table. The operation is simple, and a matching target script generation program can be quickly found with high search accuracy.
[0065] Step 206, obtaining a mapping table in the table file, the mapping table being used to store a mapping relationship between a database type, a database object, and a script generator calling control.
[0066] Among them, each script generation program call control corresponds to a script generation program. Based on the script generation program, the trigger path configuration can be performed for each script generation program call control configuration, and then the script generation program is called by triggering the script generation program call control.
[0067] Step 207, displaying the mapping table in the display page, and triggering monitoring of the script generation program call control corresponding to each database.
[0068] Among them, after the database change content is stored in the table file, the mapping table can be automatically displayed in the display page, and the script generation program call control corresponding to each database can be triggered and monitored.
[0069] Step 208, in response to monitoring a trigger operation of a script generation program calling a control corresponding to any database, calling a corresponding target script generation program according to the trigger operation.
[0070] In an embodiment of the present application, a trigger operation may refer to a click operation triggered by a user through a displayed page, such as a single-click operation or a double-click operation.
[0071] The mapping table is displayed on the display page, and the corresponding target script generation program is called according to the trigger operation, which can not only realize the automatic generation of the change script, but also allow the user to control the progress of the database change.
[0072] Step 209: Generate a change script corresponding to the database based on the target script generation program.
[0073] Step 210: perform database changes on the corresponding database according to the change script.
[0074] It should be noted that the execution process of step 201, step 202, step 209 and step 210 can be implemented in any way in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be repeated.
[0075] In one implementation of the present application, a mapping table in a table file is obtained, and the mapping table is used to store the mapping relationship between the database type, the database object and the script generator identifier; for any database, according to the database type and the target database object of the database, a matching target mapping relationship is searched in the mapping table; based on the script generator identifier in the target mapping relationship, the target script generator is called from the script generator deployed in the table file. In another implementation, a mapping table in a table file is obtained, and the mapping table is used to store the mapping relationship between the database type, the database object and the script generator call control; the mapping table is displayed in a display page, and the script generator call control corresponding to each database is triggered and monitored; in response to the trigger operation of the script generator call control corresponding to any database, the corresponding target script generator is called according to the trigger operation. The present application provides two ways to call the target script generator. The former searches for the target script generator through the mapping relationship in the mapping table, which is simple to operate, has a fast search speed and high accuracy. The latter displays the mapping table in the display page, and calls the corresponding target script generator according to the trigger operation, which can not only realize the automatic generation of the change script, but also allow the user to control the progress of the database change.
[0076] Embodiment three:
[0077] Figure 3 A flowchart of a database modification method provided in another embodiment of the present application is shown as follows: Figure 3 As shown, the method comprises the following steps:
[0078] Step 301, obtaining database change content.
[0079] Step 302, obtain the set table file, and obtain the change attributes of the database change content; determine the target data table for storing the database change content in the table file according to the change attributes; store the database change content in the target data table.
[0080] In the embodiment of the present application, the table file includes multiple data tables, and each database object corresponds to one or more data tables.
[0081] The change attribute is used to indicate the target database object corresponding to the database change content. As an example, based on the change attribute, a candidate data table corresponding to the target database object is screened out from multiple data tables; any data table in the candidate data table is used as the target data table, or, based on the data table creation time, the most recently created candidate data table is used as the target data table.
[0082] The change attribute is used to indicate whether the database change content is new content. As another example, whether the database change content is new content is determined based on the change attribute; when the database change content is new content, a new data table is created in the spreadsheet file, and the new data table is used as the target data table; when the database change content is not new content, the original database content corresponding to the database change content is obtained, and the data table where the original database content is located is used as the target data table.
[0083] When the database changes are new content, a new data table is created and the newly created data table is used as the target data table. When the database changes are not new content, the data table where the original database content is located is used as the target data table. This can better manage the database changes and facilitate backtracking.
[0084] For new content, using a new data table as the target data table can ensure the independence and integrity of the data, avoid confusion or conflict with the original data, and facilitate maintenance and backtracking. For non-new content (such as updated or deleted content), using the data table where the original database content is located as the target data table can not only ensure the continuity and consistency of the data, but also retain the data change history for subsequent backtracking. Therefore, using the above strategy to manage and store database changes not only improves the flexibility of data management, but also improves the storage efficiency of database changes.
[0085] Step 303, for any database, call a target script generation program that matches the database type and target database object of the database from the script generation program deployed in the table file, so as to generate a change script corresponding to the database based on the target script generation program.
[0086] Step 304: perform database changes on the corresponding database according to the change script.
[0087] It should be noted that the execution process of step 301 and step 304 can be implemented in any way in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be repeated.
[0088] The present application obtains the change attributes of the database change content; according to the change attributes, determines the target data table for storing the database change content in the table file; and stores the database change content in the target data table. The present application combines the change attributes of the database change content to determine the target data table for storing the database change content, which not only ensures that every change is recorded, but also improves the management and storage efficiency of the database change content and avoids data confusion.
[0089] Embodiment 4:
[0090] Figure 4 A flowchart of a database modification method provided in another embodiment of the present application is shown as follows: Figure 4 As shown, the method comprises the following steps:
[0091] Step 401, obtaining database change content.
[0092] Step 402, obtain the set table file, and store the database change content in the table file.
[0093] Step 403: for any database, call a target script generation program that matches the database type and target database object of the database from the script generation programs deployed in the table file.
[0094] Step 404, execute the target script generation program to obtain a target change statement template that matches the database type and the target database object of the database from the set change statement template; extract the statement parameters of the target change statement template based on the database change content; assemble the target change statement template and the statement parameters to obtain a change script.
[0095] The change statement template may refer to a change statement that does not include statement parameters, and the set change statement template may refer to a change statement template corresponding to each database object under each database type.
[0096] As an example, there is a mapping relationship between the database type, the database object, and the change statement template, and the target change statement template can be searched from the set change statement templates based on the mapping relationship.
[0097] The method of using change statement templates and extracting statement parameters to assemble change scripts greatly improves the efficiency of change script generation. This method avoids the tedious process of writing complex SQL statements from scratch for each change. It not only shortens the script generation time, but also reduces the script debugging and correction time caused by manual input errors.
[0098] Step 405: perform database changes on the corresponding database according to the change script.
[0099] It should be noted that the execution process of step 401, step 402, step 403 and step 405 can be implemented in any way in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be repeated.
[0100] As an example, the method also includes: generating a backup script, a change verification script and a rollback script corresponding to the database based on a target script generation program; wherein the backup script is used to back up the content before making a database change; the change verification script is used to verify whether the change script is successfully executed, and / or, to verify whether the database change result is the same as the expected result; the rollback script is used to roll back the change when the change script is not successfully executed, or the database change result is different from the expected result.
[0101] The process of generating backup scripts, change verification scripts and rollback scripts based on the target script generation program is similar to the process of generating change scripts. Taking the backup script as an example, the process of generating the backup script based on the target script generation program is as follows: from the set backup statement template, obtain the target backup statement template that matches the database type and the target database object of the database; based on the database change content, extract the statement parameters of the target backup statement template; assemble the target backup statement template and the statement parameters to obtain the backup script.
[0102] The following describes the change process of any database by combining the change script, backup script, change verification script, and rollback script:
[0103] (1) Execute the backup script to back up the database content before the change; when backing up, it is necessary to delete the objects created during the last backup.
[0104] (2) If the backup is successful, execute the change script to make database changes; if the backup is not successful, modify the backup script or modify the corresponding script generation program to regenerate the backup script, and perform backup based on the new backup script.
[0105] (3) Execute the change verification script, read the change log, check whether the change script is successfully executed, and if the change script is successfully executed, check whether the database change result is the same as the expected result.
[0106] (4) If the change script is successfully executed and the database change result is the same as the expected result, it means that the database change is successful; if the change script is not successfully executed or the database change result is different from the expected result, it means that the database change has failed. At this time, execute the rollback script, modify the change script or modify the corresponding script generation program to regenerate the change script, and execute the new change script until the change script is successfully executed and the database change result is the same as the expected result.
[0107] The change script is responsible for executing specific changes to the database structure or data, while the backup script backs up the data completely before the change to ensure that the data can be restored to the state before the change based on the rollback script when a problem occurs, thereby maintaining data consistency. The change verification script verifies the change results through preset rules and logic to ensure that the change is executed as expected, thereby improving the accuracy of database changes. Therefore, based on the change script, backup script, change verification script and rollback script, the consistency and accuracy of the database change deployment process can be ensured. In addition, these scripts also enhance the traceability of database changes. All change operations are recorded through scripts for easy tracking and verification.
[0108] The present application executes a target script generation program to obtain a target change statement template that matches the database type and target database object of the database from the set change statement template; extracts the statement parameters of the target change statement template based on the database change content; and assembles the target change statement template and the statement parameters to obtain a change script. The method of using a change statement template and extracting statement parameters to assemble a change script greatly improves the efficiency of generating change scripts. This method avoids the tedious process of writing complex SQL statements from scratch for each change, which not only shortens the script generation time, but also reduces the script debugging and correction time caused by manual input errors.
[0109] Embodiment five:
[0110] Figure 5 A schematic diagram of the structure of a database modification device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, it includes a first acquisition module 501, a second acquisition module 502, a script generation module 503 and a change module 504.
[0111] Among them, the first acquisition module 501 is used to obtain database change content, wherein the database change content is used to change at least one database, and the database change content corresponds to a target database object; the second acquisition module 502 is used to obtain a set table file and store the database change content in the table file, wherein the table file is used to store the attribute content of the database object; the script generation module 503 is used to call the target script generation program that matches the database type and the target database object of the database from the script generation program deployed in the table file for any database, so as to generate a change script corresponding to the database based on the target script generation program; the change module 504 is used to perform database changes on the corresponding database according to the change script.
[0112] As a possible implementation method, the script generation module is used to: obtain a mapping table in a table file, the mapping table is used to store the mapping relationship between the database type, the database object and the script generation program identifier; for any database, according to the database type and the target database object of the database, find a matching target mapping relationship in the mapping table; based on the script generation program identifier in the target mapping relationship, call the target script generation program from the script generation program deployed in the table file.
[0113] As a possible implementation method, the script generation module is used to: obtain a mapping table in a table file, the mapping table being used to store the mapping relationship between database types, database objects and script generation program call controls; display the mapping table in a display page, and trigger monitoring of the script generation program call controls corresponding to each database; in response to monitoring a trigger operation of a script generation program call control corresponding to any database, call the corresponding target script generation program according to the trigger operation.
[0114] As a possible implementation method, the table file includes multiple data tables, and the second acquisition module is used to: obtain the change attributes of the database change content; determine the target data table for storing the database change content in the table file according to the change attributes; and store the database change content in the target data table.
[0115] As a possible implementation method, the second acquisition module is used to: determine whether the database change content is new content based on the change attributes; if the database change content is new content, create a new data table in the table file, and use the new data table as the target data table; if the database change content is not new content, obtain the original database content corresponding to the database change content, and use the data table where the original database content is located as the target data table.
[0116] As a possible implementation method, the script generation module is used to: execute a target script generation program to obtain a target change statement template that matches the database type and target database object of the database from the set change statement template; extract statement parameters of the target change statement template based on the database change content; assemble the target change statement template and statement parameters to obtain a change script.
[0117] As a possible implementation method, the script generation module is also used to: generate a backup script, a change verification script and a rollback script corresponding to the database based on a target script generation program; wherein the backup script is used to back up the content before making a database change; the change verification script is used to verify whether the change script is successfully executed, and / or, to verify whether the database change result is the same as the expected result; the rollback script is used to roll back the change when the change script is not successfully executed, or the database change result is different from the expected result.
[0118] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and will not be repeated here.
[0119] Embodiment six:
[0120] Figure 6 A schematic diagram of the structure of an electronic device provided for an embodiment of the present application. Among them, the electronic device 600 in this embodiment is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0121] like Figure 6 As shown, the electronic device 600 includes: a memory 610, a processor 620, and computer instructions stored in the memory 610 and executable on the processor 620.
[0122] When the processor 620 executes the instruction, the database changing method provided in the above embodiment is implemented.
[0123] Furthermore, the electronic device 600 further includes:
[0124] The communication interface 630 is used for communication between the memory 610 and the processor 620 .
[0125] The memory 610 is used to store computer instructions that can be executed on the processor 620 .
[0126] The memory 610 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0127] The processor 620 is used to implement the database changing method of the above embodiment when executing the program.
[0128] If the memory 610, the processor 620 and the communication interface 630 are implemented independently, the communication interface 630, the memory 610 and the processor 620 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0129] Optionally, in a specific implementation, if the memory 610, the processor 620 and the communication interface 630 are integrated on a chip, the memory 610, the processor 620 and the communication interface 630 can communicate with each other through an internal interface.
[0130] The processor 620 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0131] In order to implement the above embodiments, the present application also proposes a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to enable a computer to execute the above method.
[0132] In order to implement the above embodiments, the present application also proposes a computer program product, including a computer program, which implements the above method when executed by a processor.
[0133] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0134] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0135] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0136] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0137] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0138] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0139] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk or an optical disk, etc.
[0140] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0141] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A database modification method, characterized in that: The following steps are involved: Acquire database change content, wherein the database change content is used to change at least one database, and the database change content corresponds to a target database object; Obtaining a set table file, and storing the database change content in the table file, wherein the table file is used to store the attribute content of the database object; For any of the databases, calling a target script generation program that matches the database type of the database and the target database object from the script generation program deployed in the table file, so as to generate a change script corresponding to the database based on the target script generation program; According to the change script, a database change is performed on the corresponding database.
2. The method according to claim 1, characterized in that For any of the databases, calling a target script generation program that matches the database type of the database and the target database object from the script generation program deployed in the table file includes: Obtaining a mapping table in the table file, wherein the mapping table is used to store a mapping relationship between a database type, a database object, and a script generation program identifier; For any of the databases, searching for a matching target mapping relationship in the mapping table according to the database type of the database and the target database object; Based on the script generation program identifier in the target mapping relationship, the target script generation program is called from the script generation programs deployed in the table file.
3. The method according to claim 1, characterized in that For any of the databases, calling a target script generation program that matches the database type of the database and the target database object from the script generation program deployed in the table file includes: Obtaining a mapping table in the table file, wherein the mapping table is used to store a mapping relationship between a database type, a database object, and a script generator calling a control; Displaying the mapping table on a display page, and triggering and monitoring the script generation program call control corresponding to each database; In response to monitoring a trigger operation of calling a control of the script generation program corresponding to any of the databases, the corresponding target script generation program is called according to the trigger operation.
4. The method according to claim 1, characterized in that: The table file includes a plurality of data tables, and storing the database change content in the table file includes: Obtaining the change attributes of the database change content; According to the change attribute, determining in the table file a target data table for storing the database change content; The database change content is stored in the target data table.
5. The method according to claim 4, characterized in that Determining, in the table file, a target data table for storing the database change content according to the change attribute includes: Determining whether the database change content is new content according to the change attribute; In the case where the database change content is new content, a new data table is created in the table file, and the new data table is used as the target data table; In the case that the database change content is not new content, the original database content corresponding to the database change content is obtained, and the data table where the original database content is located is used as the target data table.
6. The method according to claim 1, characterized in that The generating program based on the target script generates a change script corresponding to the database, including: Executing the target script generation program to obtain a target change statement template that matches the database type of the database and the target database object from the set change statement templates; Based on the database change content, extracting statement parameters of the target change statement template; The target change statement template and the statement parameters are assembled to obtain the change script.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Based on the target script generation program, generate a backup script, a change verification script and a rollback script corresponding to the database; Among them, the backup script is used to back up the content before making a database change; the change verification script is used to verify whether the change script is successfully executed, and / or, to verify whether the database change result is the same as the expected result; the rollback script is used to roll back the change if the change script is not successfully executed, or the database change result is different from the expected result.
8. A database changing device, characterized in that: include: A first acquisition module is used to acquire database change content, wherein the database change content is used to change at least one database, and the database change content corresponds to a target database object; A second acquisition module is used to acquire a set table file and store the database change content in the table file, wherein the table file is used to store the attribute content of the database object; A script generation module, for calling, for any of the databases, a target script generation program that matches the database type of the database and the target database object from the script generation program deployed in the table file, so as to generate a change script corresponding to the database based on the target script generation program; A change module is used to perform database changes on the corresponding database according to the change script.
9. The device according to claim 8, characterized in that The script generation module is used to: Obtaining a mapping table in the table file, wherein the mapping table is used to store a mapping relationship between a database type, a database object, and a script generation program identifier; For any of the databases, searching for a matching target mapping relationship in the mapping table according to the database type of the database and the target database object; Based on the script generation program identifier in the target mapping relationship, the target script generation program is called from the script generation programs deployed in the table file.
10. The device according to claim 8, characterized in that The script generation module is used to: Obtaining a mapping table in the table file, wherein the mapping table is used to store a mapping relationship between a database type, a database object, and a script generator calling a control; Displaying the mapping table on a display page, and triggering and monitoring the script generation program call control corresponding to each database; In response to monitoring a trigger operation of calling a control of the script generation program corresponding to any of the databases, the corresponding target script generation program is called according to the trigger operation.
11. The device according to claim 8, characterized in that The table file includes a plurality of data tables, and the second acquisition module is used for: Obtaining the change attributes of the database change content; According to the change attribute, determining in the table file a target data table for storing the database change content; The database change content is stored in the target data table.
12. The device according to claim 11, characterized in that The second acquisition module is used for: Determining whether the database change content is new content according to the change attribute; In the case where the database change content is new content, a new data table is created in the table file, and the new data table is used as the target data table; In the case that the database change content is not new content, the original database content corresponding to the database change content is obtained, and the data table where the original database content is located is used as the target data table.
13. The device according to claim 8, characterized in that The script generation module is used to: Executing the target script generation program to obtain a target change statement template that matches the database type of the database and the target database object from the set change statement templates; Based on the database change content, extracting statement parameters of the target change statement template; The target change statement template and the statement parameters are assembled to obtain the change script.
14. The device according to any one of claims 8 to 13, characterized in that: The script generation module is also used for: Based on the target script generation program, generate a backup script, a change verification script and a rollback script corresponding to the database; Among them, the backup script is used to back up the content before making a database change; the change verification script is used to verify whether the change script is successfully executed, and / or, to verify whether the database change result is the same as the expected result; the rollback script is used to roll back the change if the change script is not successfully executed, or the database change result is different from the expected result.
15. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
17. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 7.