Database table structure updating method and device, equipment and storage medium
By comparing the version numbers of the relational database table structure template file and the target relational database, and updating the database table structure using the XML format template file, the problem of complex and timely table structure updates in existing technologies is solved, ensuring timely response to project requirements.
Patent Information
- Application Number
- CN202411298396.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-10
AI Technical Summary
In existing technologies, relational database table structures are complex to update and cannot respond to changes in project requirements in a timely manner, leading to functional errors.
By comparing the first version number obtained from the relational database table structure template file with the second version number of the target relational database, the table structure of the target relational database is updated using the XML format template file, ensuring that the table structure is synchronized to the latest state in a timely manner.
It enables timely updates to the relational database table structure, avoiding update omissions caused by patch package priority settings and ensuring the normal operation of project functions.
Smart Images

Figure CN119293052A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to but is not limited to the field of database technology, and in particular to a method, device, equipment, and storage medium for updating a database table structure. Background Art
[0002] As the project progresses and customer needs change, the table structure in the relational database changes more and more, and the project site needs to update the relational database table in real time to meet project needs. Due to the large number of project sites and the diverse customer needs corresponding to each project site, the table structure update is complex and diverse. In the prior art, the way to update the relational database table corresponding to the project site is to put the update SQL statement required for each update into a patch package, and upgrade the relational database table by executing the corresponding patch package, and execute one patch package for one upgrade operation. However, the project site often faces the situation of multiple tasks being carried out at the same time, and the deployment of patches needs to set priorities according to the actual needs and urgency of the project. Therefore, some non-critical or non-urgent patch packages may be shelved to give priority to more important or more urgent tasks, and the relational database cannot be updated in time, resulting in project function errors. Summary of the invention
[0003] The embodiments of the present application provide a database table structure updating method, apparatus, device, and storage medium, which can timely update and maintain the relational database table structure to meet project requirements.
[0004] In a first aspect, an embodiment of the present application provides a method for updating a database table structure, comprising:
[0005] Obtaining a relational database table structure template file, the relational database table structure template file comprising first table structure information and a first version number corresponding to a target table structure, wherein the target table structure is a table structure of a target relational database, the file format of the relational database table structure template file is an XML format, and the first version number is used to uniquely indicate an update status of the relational database table structure template file, and a larger value of the first version number indicates a newer update status of the corresponding table structure;
[0006] Determine a second version number corresponding to the target relational database, and compare the first version number with the second version number to obtain a first comparison result, wherein the second version number is used to uniquely identify an update status of a table structure corresponding to the target relational database, and a larger value of the second version number indicates a newer update status of the corresponding table structure;
[0007] When the first comparison result indicates that the first version number is greater than the second version number, the table structure of the target relational database is updated based on the first table structure information and the second table structure information of the target relational database.
[0008] In some embodiments, updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database includes:
[0009] When it is detected that the second table structure information indicates that the target relational database has no table, creating a first relational database table in the target relational database based on the first table structure information;
[0010] Generate the second version number, save the second version number to the target relational database, and establish a mapping relationship between the second version number and the first relational database table, wherein the value of the first version number is the same as the value of the second version number.
[0011] In some embodiments, the first table structure information corresponds to a first table name, the second table structure information corresponds to a second table name, and updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database includes:
[0012] When the second table name does not match the first table name, creating a first relational library table in the target relational database based on the first table structure information;
[0013] Generate the second version number, save the second version number to the target relational database, and establish a mapping relationship between the second version number and the first relational database table, wherein the value of the first version number is the same as the value of the second version number.
[0014] In some embodiments, the number of the second table structure information is multiple, each second table structure information corresponds to a second table name, each second table name corresponds to a reference table, and updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database includes:
[0015] When any one of the second table names matches the first table name, determining the second table name corresponding to the first table name as the target table name;
[0016] Comparing the first table structure information with the target table structure information to obtain a second comparison result, wherein the target table structure information is the second table structure information corresponding to the target table name;
[0017] updating the table structure of the target relational database based on the second comparison result;
[0018] Update the current second version number to the current first version number.
[0019] In some embodiments, updating the table structure of the target relational database based on the second comparison result includes:
[0020] When the second comparison result indicates that there is a difference between the first table structure information and the target table structure information, replacing the target table structure information with the first table structure information;
[0021] or,
[0022] When the second comparison result indicates that there is a difference between the first table structure information and the target table structure information, target difference information is obtained from the comparison result, the target difference information including a difference attribute identifier and a target content corresponding to the difference attribute identifier, wherein the difference attribute identifier is an attribute identifier in the target table structure information that is inconsistent with the first table structure information, and the target content is the content corresponding to the difference attribute identifier in the first table structure information;
[0023] The target content replaces the content to be updated, wherein the content to be updated is the content corresponding to the difference attribute identifier in the target table structure information.
[0024] In some embodiments, the method further comprises:
[0025] When it is detected that the content of the relational database table structure template file has changed, a new second version number corresponding to the target relational database is re-determined, and the current relational database table structure template file includes new first table structure information and a new first version number corresponding to the target table structure;
[0026] Re-comparing the new first version number and the new second version number to obtain a new first comparison result;
[0027] When the new first comparison result indicates that the new first version number is greater than the new second version number, updating the table structure of the target relational database based on the new first table structure information and the new second table structure information of the target relational database;
[0028] Update the current second version number to the current first version number.
[0029] In some embodiments, after updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database, the method further includes:
[0030] Generate a log file, wherein the log file includes operation records and update records of the target relational database;
[0031] The log file is saved.
[0032] In a second aspect, an embodiment of the present application provides a control device, comprising at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions executable by the at least one control processor, and the instructions are executed by the at least one control processor so that the at least one control processor can execute the database table structure updating method as described in the first aspect.
[0033] In a third aspect, an embodiment of the present application further provides an electronic device, comprising the control device of the second aspect.
[0034] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the database table structure updating method as described in the first aspect.
[0035] The embodiment of the present application provides a method, apparatus, device, and storage medium for updating a database table structure, the method comprising: obtaining a relational database table structure template file, the relational database table structure template file comprising first table structure information and a first version number corresponding to a target table structure, wherein the target table structure is a table structure of a target relational database, the file format of the relational database table structure template file is an XML format, the first version number is used to uniquely indicate an update status of the relational database table structure template file, and a larger value of the first version number corresponds to a newer update status of the corresponding table structure; determining a second version number corresponding to the target relational database, and comparing the first version number with the second version number to obtain a first comparison result, wherein the second version number is used to uniquely identify an update status of the table structure corresponding to the target relational database, and a larger value of the second version number corresponds to a newer update status of the corresponding table structure; when the first comparison result indicates that the first version number is greater than the second version number, updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database. According to the solution provided in the embodiment of the present application, the content of the relational library table structure template file in XML format is used as the update trigger source. When it is detected that the version number in the template file is different from the version number stored in the target relational database, the table structure in the target relational database is updated according to the template file, and the relational database table structure can be updated and maintained in time to meet project requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flowchart of the steps of a method for updating a database table structure provided by an embodiment of the present application;
[0037] Figure 2 is a schematic diagram of a database table structure updating method provided by another embodiment of the present application;
[0038] Figure 3 It is a structural diagram of a control device provided in another embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0040] It is understood that although the functional modules are divided in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flow chart. The terms "first", "second", etc. in the specification, claims or the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0041] As the project progresses and customer needs change, the table structure in the relational database changes more and more, and the project site needs to update the relational database table in real time to meet project needs. Due to the large number of project sites and the diverse customer needs corresponding to each project site, the table structure update is complex and diverse. In the prior art, the way to update the relational database table corresponding to the project site is to put the update SQL statement required for each update into a patch package, and upgrade the relational database table by executing the corresponding patch package, and execute one patch package for one upgrade operation. However, the project site often faces the situation of multiple tasks being carried out at the same time, and the deployment of patches needs to set priorities according to the actual needs and urgency of the project. Therefore, some non-critical or non-urgent patch packages may be shelved to give priority to more important or more urgent tasks, and the relational database cannot be updated in time, resulting in project function errors.
[0042] To solve the above-mentioned problems, an embodiment of the present application provides a database table structure updating method, apparatus, device, and storage medium, the method comprising: obtaining a relational library table structure template file, the relational library table structure template file comprising first table structure information and a first version number corresponding to a target table structure, wherein the target table structure is a table structure of a target relational database, the file format of the relational library table structure template file is an XML format, the first version number is used to uniquely indicate an update status of the relational library table structure template file, and a larger value of the first version number corresponds to a newer update status of the table structure; determining a second version number corresponding to the target relational database, comparing the first version number with the second version number to obtain a first comparison result, wherein the second version number is used to uniquely identify an update status of the table structure corresponding to the target relational database, and a larger value of the second version number corresponds to a newer update status of the table structure; when the first comparison result indicates that the first version number is greater than the second version number, updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database. According to the solution provided in the embodiment of the present application, the content of the relational library table structure template file in XML format is used as the update trigger source. When it is detected that the version number in the template file is different from the version number stored in the target relational database, the table structure in the target relational database is updated according to the template file, and the relational database table structure can be updated and maintained in time to meet project requirements.
[0043] The embodiments of the present application are further described below in conjunction with the accompanying drawings.
[0044] refer to Figure 1 , Figure 1 This is a flowchart of a method for updating a database table structure provided by an embodiment of the present application. The present application embodiment provides a method for updating a database table structure, which includes but is not limited to the following steps:
[0045] Step S10, obtaining a relational database table structure template file, the relational database table structure template file including first table structure information and a first version number corresponding to a target table structure, wherein the target table structure is a table structure of a target relational database, the file format of the relational database table structure template file is an XML format, and the first version number is used to uniquely indicate an update status of the relational database table structure template file, and a larger value of the first version number indicates a newer update status of the corresponding table structure.
[0046] Specifically, the relational library table structure template file of the present embodiment is a collection of a pre-prepared relational database table structure (i.e., the target table structure) and its related setting parameters, including table type (the table type of the present embodiment can be a static table, or a dynamic table that requires periodic table creation), table structure information, table comments, table index, first version number and other information. These elements have been configured according to preset application requirements, and the relational library table structure template file of the present embodiment can be used directly to create a new database table without having to build it from scratch.
[0047] Specifically, XML is a semi-structured data format that allows users to customize data structures and models according to their needs. Based on this feature, this embodiment sets the relational library table structure template file to XML format, so that it can flexibly adapt to various complex data structures and table structure update requirements.
[0048] Specifically, the relational library table structure template file of this embodiment can be constructed by the background administrator writing and entering information in the background of the database system, or it can be generated by obtaining information input from the human-computer interface. For example, first write the project version and related relationship table information and other configurations into an xml file, input the target version and relationship library information to be upgraded through the human-computer interface, and then update the target table structure. Each time the current relational library table structure template file is modified or updated, the first version number of the relational library table structure template file is updated once.
[0049] It should be noted that the executor of the database table structure updating method of this embodiment can be a database update tool stored in the target relational database. This embodiment does not limit the specific time interval for obtaining the relational library table structure template file. It can be obtained in real time or periodically through the database update tool. Technical personnel in this field can adjust it according to actual needs.
[0050] It can be understood that since the relational library table structure template file of this embodiment includes a first version number, and the first version number uniquely indicates the update status of the relational library table structure template file, the larger the value of the first version number, the newer the update status of the corresponding table structure, indicating that the relational library table structure template file will be updated according to actual project requirements. The update of the relational library table structure template file means that the target table structure required for the current project needs to be updated. Therefore, obtaining the relational library table structure template file can provide an effective data basis for the subsequent update of the target table structure.
[0051] Step S20, determine the second version number corresponding to the target relational database, compare the first version number and the second version number to obtain a first comparison result, wherein the second version number is used to uniquely identify the update status of the table structure corresponding to the target relational database, and the larger the value of the second version number, the newer the update status of the corresponding table structure.
[0052] Specifically, the second version number corresponding to the target relational database is used to uniquely identify the update status of the table structure corresponding to the target relational database. Referring to the description of the above embodiment, the relational library table structure template file includes a first version number. The first version number and the second version number are combined to determine whether the target table structure of the current target relational database needs to be updated. Therefore, determining the second version number corresponding to the target relational database can provide an effective data basis for subsequent comparison operations with the first version number of the relational library table structure template file, as well as for determining whether the target table structure needs to be updated.
[0053] Step S30: When the first comparison result indicates that the first version number is greater than the second version number, the table structure of the target relational database is updated based on the first table structure information and the second table structure information of the target relational database.
[0054] It can be understood that the existing method of updating the corresponding relational database table of the project site is to put the update sql statement required for each update into the patch package, and upgrade the relational database table by executing the corresponding patch package. Executing one patch package corresponds to one upgrade operation. If an upgrade error or omission leads to an error in the relational database table structure and is not discovered in time, it will be extremely difficult to repair it later. Based on this, in this embodiment, the first comparison result of the first version number and the second version number is the trigger source of the update operation of the target table structure. Since the information in the relational database table structure template file is the information of the target table structure required by the current project, the information corresponding to the current latest version of the relational database table structure template file is used as the target update information as the data basis for updating the target table structure. When the first comparison result indicates that the first version number is greater than the second version number, it means that the current target table structure needs to be updated. Based on the first table structure information and the second table structure information of the target relational database, it is updated, so that the target relational database can be maintained separately. Compared with the existing patch package solution, there is no omission, and the target table structure is updated to the latest version in time to meet the project requirements.
[0055] Specifically, Figure 1 Step S30 includes but is not limited to the following steps:
[0056] Step S31, when it is detected that the second table structure information indicates that the target relational database has no table, a first relational database table is created in the target relational database based on the first table structure information;
[0057] Step S32, generating a second version number, saving the second version number to the target relational database, and establishing a mapping relationship between the second version number and the first relational database table, wherein the value of the first version number is the same as the value of the second version number.
[0058] Understandably, reference Figure 2When it is detected that the second table structure information indicates that the target relational database has not created a table, a first relational library table is created in the target relational database based on the first table structure information in the current relational library table structure template file, and a second version number that is the same as the current first version number is generated (for example, since it is the first time to create a table, the second version number is initialized to 0), and a mapping relationship between the second version number and the first relational library table is established as a basis for determining whether to subsequently update the target table structure.
[0059] Specifically, in some embodiments, the first table structure information corresponds to a first table name, and the second table structure information corresponds to a second table name. Figure 1 Step S30 includes but is not limited to the following steps:
[0060] Step S33: when the second table name does not match the first table name, create a first relational database table in the target relational database based on the first table structure information;
[0061] Step S34, generating a second version number, saving the second version number to the target relational database, and establishing a mapping relationship between the second version number and the first relational database table, wherein the value of the first version number is the same as the value of the second version number.
[0062] It should be noted that this embodiment does not limit the specific number of the first table names, nor does it limit the specific number of the second table names, which depends on the actual application project requirements.
[0063] Understandably, reference Figure 2 In the case where the first table structure information corresponds to the first table name and the second table structure information corresponds to the second table name, when the second table name does not match the first table name, it means that the target relational database does not contain information about the table that needs to be updated or established in the current relational library table structure template file, then it is currently necessary to establish a table corresponding to the first table name in the target relational database. At this time, this embodiment creates the first relational library table in the target relational database based on the first table structure information, and generates a second version number that is the same as the first version number in the current relational library table structure template file, saves the second version number to the target relational database, and establishes a mapping relationship between the second version number and the first relational library table as a basis for subsequent judgment of updating the target table structure.
[0064] Specifically, in some embodiments, the number of second table structure information is multiple, each second table structure information corresponds to a second table name, and each second table name corresponds to a reference table. Figure 1 Step S30 includes but is not limited to the following steps:
[0065] Step S35, when any second table name matches the first table name, the second table name corresponding to the first table name is determined as the target table name;
[0066] Step S36, comparing the first table structure information and the target table structure information to obtain a second comparison result, wherein the target table structure information is the second table structure information corresponding to the target table name;
[0067] Step S37, updating the table structure of the target relational database based on the second comparison result;
[0068] Step S38, updating the current second version number to the current first version number.
[0069] Specifically, refer to Figure 2 When any second table name matches the first table name, it means that the table corresponding to the target table name (i.e., the second table name corresponding to the first table name) in the target relational database needs to be updated according to the information contained in the current relational database table structure template file, and the first table structure information is compared with the second table structure information corresponding to the target table name (i.e., the target table structure information), to obtain a second comparison result, and the table structure of the target relational database is updated based on the second comparison result. After the update is completed, the current second version number is updated to the current first version number, thereby ensuring that all target table structures in the target relational database are updated to the latest version that meets the project requirements.
[0070] Specifically, step S37 includes but is not limited to the following steps:
[0071] When the second comparison result indicates that there is a difference between the first table structure information and the target table structure information, the first table structure information replaces the target table structure information;
[0072] or,
[0073] When the second comparison result indicates that there is a difference between the first table structure information and the target table structure information, target difference information is obtained from the comparison result, the target difference information including a difference attribute identifier and a target content corresponding to the difference attribute identifier, wherein the difference attribute identifier is an attribute identifier in the target table structure information that is inconsistent with the first table structure information, and the target content is the content corresponding to the difference attribute identifier in the first table structure information;
[0074] The target content replaces the content to be updated, wherein the content to be updated is the content corresponding to the difference attribute identifier in the target table structure information.
[0075] Specifically, the second comparison result of this embodiment includes a table structure difference judgment result and target difference information, the target difference information includes a difference attribute identifier and a target content corresponding to the difference attribute identifier, wherein the difference attribute identifier is an attribute identifier (such as a field, primary key, foreign key, index, etc.) in the target table structure information that is inconsistent with the first table structure information, and the target content is the content corresponding to the difference attribute identifier in the first table structure information. There are two corresponding situations for the table structure difference judgment result: there is a difference between the first table structure information and the target table structure information, or there is no difference between the first table structure information and the target table structure information.
[0076] Specifically, when it is determined that the second comparison result indicates that there is a difference between the first table structure information and the target table structure information, this embodiment has two ways to update the existing table structure of the target relational database: replacing the target table structure information with the first table structure information, or obtaining the difference attribute identifier and the target content corresponding to the difference attribute identifier from the comparison result, and replacing the target content with the content to be updated, wherein the content to be updated is the content corresponding to the difference attribute identifier in the target table structure information, and the target content is obtained from the first table structure information, thereby ensuring that all target table structures and related information in the target relational database are updated to the latest version that meets project requirements.
[0077] In addition, in some embodiments, the database table structure update method further includes but is not limited to the following steps:
[0078] Step S41, when it is detected that the content of the relational database table structure template file has changed, a new second version number corresponding to the target relational database is re-determined, and the current relational database table structure template file includes new first table structure information and a new first version number corresponding to the target table structure;
[0079] Step S42, re-comparing the new first version number and the new second version number to obtain a new first comparison result;
[0080] Step S43, when the new first comparison result indicates that the new first version number is greater than the new second version number, updating the table structure of the target relational database based on the new first table structure information and the new second table structure information of the target relational database;
[0081] Step S44, updating the current second version number to the current first version number.
[0082] It should be noted that, while monitoring whether the table structure in the target relational database is updated to be the same as the table structure related information stored in the relational database table structure template file, the embodiment also monitors the update status of the relational database table structure template file. When it is detected that the content of the relational database table structure template file has changed, the update status of the relational database table structure template file is re-executed. Figure 1The related steps of steps S10 to S30 are, namely, re-determining the new second version number corresponding to the target relational database, the current relational database table structure template file includes the new first table structure information and the new first version number corresponding to the target table structure; re-comparing the new first version number and the new second version number to obtain a new first comparison result; when the new first comparison result indicates that the new first version number is greater than the new second version number, updating the table structure of the target relational database based on the new first table structure information and the new second table structure information of the target relational database; updating the current second version number to the current first version number, thereby ensuring that all target table structures and related information in the target relational database are updated to the latest version that meets project requirements.
[0083] In addition, in some embodiments, when executing Figure 1 After step S30, the database table structure updating method provided in the embodiment of the present application further includes but is not limited to the following steps:
[0084] Step S44, generating a log file, wherein the log file includes operation records and update records of the target relational database;
[0085] Step S45, saving the log file.
[0086] Understandably, reference Figure 2 After updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database, this embodiment generates operation records and update records involved in the update operation process, forms a log file, and saves it. If an error or data loss occurs during the update of the table structure of the target relational database, the data can be restored to a certain state through the records in the log file to ensure the integrity and security of the data. Or when a failure occurs in the target relational database, the log file can serve as an important basis for troubleshooting the problem and help administrators quickly locate the cause of the problem.
[0087] like Figure 3 As shown, Figure 3 is a structural diagram of a control device provided by an embodiment of the present application. The present invention also provides a control device 500, including:
[0088] The processor 510 may be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0089] The memory 520 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 520 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 520, and the processor 510 calls and executes the database table structure update method of the embodiment of this application;
[0090] Input / output interface 530, used to implement information input and output;
[0091] Communication interface 540, used to realize communication interaction between the present apparatus and other devices, which can be realized by wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.);
[0092] bus 550 , which transmits information between the various components of the device (e.g., processor 510 , memory 520 , input / output interface 530 , and communication interface 540 );
[0093] The processor 510 , the memory 520 , the input / output interface 530 and the communication interface 540 are connected to each other in communication within the device via the bus 550 .
[0094] In addition, an embodiment of the present application further provides an electronic device, including the control device 500 of the above embodiment.
[0095] In addition, an embodiment of the present application further provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the above-mentioned database table structure updating method is implemented.
[0096] As a non-transient computer-readable storage medium, the memory can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage devices. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and are implemented to be located in one place, or may also be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0097] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically include computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0098] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present invention. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present invention.
Claims
1. A method for updating a database table structure, characterized in that: include: Obtaining a relational database table structure template file, the relational database table structure template file comprising first table structure information and a first version number corresponding to a target table structure, wherein the target table structure is a table structure of a target relational database, the file format of the relational database table structure template file is an XML format, and the first version number is used to uniquely indicate an update status of the relational database table structure template file, and a larger value of the first version number indicates a newer update status of the corresponding table structure; Determine a second version number corresponding to the target relational database, and compare the first version number with the second version number to obtain a first comparison result, wherein the second version number is used to uniquely identify an update status of a table structure corresponding to the target relational database, and a larger value of the second version number indicates a newer update status of the corresponding table structure; When the first comparison result indicates that the first version number is greater than the second version number, the table structure of the target relational database is updated based on the first table structure information and the second table structure information of the target relational database.
2. The method for updating the database table structure according to claim 1, characterized in that: Updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database includes: When it is detected that the second table structure information indicates that the target relational database has no table, a first relational database table is created in the target relational database based on the first table structure information; Generate the second version number, save the second version number to the target relational database, and establish a mapping relationship between the second version number and the first relational database table, wherein the value of the first version number is the same as the value of the second version number.
3. The method for updating the database table structure according to claim 1, characterized in that: The first table structure information corresponds to a first table name, the second table structure information corresponds to a second table name, and updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database includes: When the second table name does not match the first table name, creating a first relational library table in the target relational database based on the first table structure information; Generate the second version number, save the second version number to the target relational database, and establish a mapping relationship between the second version number and the first relational database table, wherein the value of the first version number is the same as the value of the second version number.
4. The method for updating the database table structure according to claim 3, characterized in that: There are multiple second table structure information, each second table structure information corresponds to a second table name, each second table name corresponds to a reference table, and updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database includes: When any one of the second table names matches the first table name, determining the second table name corresponding to the first table name as the target table name; Comparing the first table structure information with the target table structure information to obtain a second comparison result, wherein the target table structure information is the second table structure information corresponding to the target table name; updating the table structure of the target relational database based on the second comparison result; Update the current second version number to the current first version number.
5. The method for updating the database table structure according to claim 4, characterized in that: Updating the table structure of the target relational database based on the second comparison result includes: When the second comparison result indicates that there is a difference between the first table structure information and the target table structure information, replacing the target table structure information with the first table structure information; or, When the second comparison result indicates that there is a difference between the first table structure information and the target table structure information, target difference information is obtained from the comparison result, the target difference information including a difference attribute identifier and a target content corresponding to the difference attribute identifier, wherein the difference attribute identifier is an attribute identifier in the target table structure information that is inconsistent with the first table structure information, and the target content is the content corresponding to the difference attribute identifier in the first table structure information; The target content replaces the content to be updated, wherein the content to be updated is the content corresponding to the difference attribute identifier in the target table structure information.
6. The method for updating the database table structure according to claim 1, characterized in that: The method further comprises: When it is detected that the content of the relational database table structure template file has changed, a new second version number corresponding to the target relational database is re-determined, and the current relational database table structure template file includes new first table structure information and a new first version number corresponding to the target table structure; Re-comparing the new first version number and the new second version number to obtain a new first comparison result; When the new first comparison result indicates that the new first version number is greater than the new second version number, updating the table structure of the target relational database based on the new first table structure information and the new second table structure information of the target relational database; Update the current second version number to the current first version number.
7. The method for updating the database table structure according to claim 1, characterized in that: After updating the table structure of the target relational database based on the first table structure information and the second table structure information of the target relational database, the method further includes: Generate a log file, wherein the log file includes operation records and update records of the target relational database; The log file is saved.
8. A control device, characterized in that: It includes at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to execute the database table structure updating method as described in any one of claims 1 to 7.
9. An electronic device, characterized in that: Comprising the control device as claimed in claim 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the database table structure updating method according to any one of claims 1 to 7.