A kind of automatic database updating method and system
Through the automated database update method, threads are used to automatically update the data table structure, table types, stored procedures and basic data tables of the database, which solves the problems of repeated work and errors caused by manual operations in the existing technology, and improves the efficiency of updates. Efficiency and cost effectiveness.
Patent Information
- Application Number
- CN201811444105.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-11-29
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2038-11-29
AI Technical Summary
In the existing technology, database updates require manual operations by database administrators, resulting in increased duplication of work and error-proneness.
Using an automated database update method, the preset update requirement information is stored in the standard source database, configuration information is obtained and update instructions are generated, and threads are used to update the target database, including data table structure, table type, stored procedures and basic data tables. of automatic updates.
This avoids manual update errors, increases the update rate, and reduces labor investment costs.
Smart Images

Figure CN109814895B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to an automatic database updating method and system. Background Art
[0002] As traditional database technology matures, computer network technology develops rapidly, and its application scope expands, database applications have been generally built on computer networks. At this time, the centralized database system shows its shortcomings, and data has been distributed and stored on the network according to actual needs. The addition and change of business requirements will lead to changes in data table structure, table type, storage process, basic data and other related data. In a distributed cloud system, each customer has its own independent database. The existing model for updating the customer's database requires the database administrator to update manually, which requires a lot of repetitive work, and manual operation can easily lead to update errors. Summary of the invention
[0003] In order to overcome the deficiencies of the prior art, one of the purposes of the present invention is to provide an automated database updating method, which can solve the problem that the existing mode of updating the customer's database requires manual updating by the database administrator, thereby requiring a large amount of repetitive work, and the update errors are easily caused by manual operation.
[0004] The second purpose of the present invention is to provide an automated database update system, which can solve the problem that the existing mode of updating the customer's database requires manual updating by the database administrator, thereby requiring a lot of repetitive work and easily causing update errors due to manual operation.
[0005] One of the purposes of the present invention is achieved by the following technical solution:
[0006] An automated database updating method comprises the following steps:
[0007] Step S1, storing the update data in a preset standard source database according to preset update requirement information, and obtaining configuration information of the required update, wherein the configuration information includes data table structure information, table type information, storage process information and basic data table information, and the update data includes data table structure data, table type data, storage process data and basic data table data;
[0008] Step S2, reading the configuration information, and generating an update instruction containing the data table structure information, the table type information, the storage process information and the basic data table according to the configuration information;
[0009] Step S3, monitoring the update instruction, and creating a thread according to the update instruction;
[0010] Step S4: According to the update instruction and the preset standard source database, the target database is updated using the thread.
[0011] Furthermore, the step S4 is specifically as follows:
[0012] Data table structure update, using the thread to update the target database according to the data table structure information and the preset standard source database;
[0013] Table type update, according to the table type information and the preset standard source database using the thread to update the target database;
[0014] Stored procedure update, using the thread to update the target database according to the stored procedure information and the preset standard source database;
[0015] The basic data table is updated, and the target database is updated using the thread according to the basic data table and the preset standard source database.
[0016] Furthermore, the data table structure update is specifically as follows: using the thread to extract all system object tables in the target database to obtain a system object table set, determining the data table structure update type of the system object table set according to the data table structure information, and updating the system object table set according to the data table structure update type and the preset standard source database.
[0017] Furthermore, the data table structure update type of the system object table set is determined based on the data table structure information, and the system object table is updated based on the data table structure update type and the preset standard source database as follows: when the data table structure information already exists in the system object table set, the data table structure update type is data table structure update, the data table structure data in the preset standard source database is extracted, and the data table structure data in the system object table set is replaced by the data table structure data; when the data table structure information does not exist in the system object table set, the data table structure update type is data table structure addition, and the data table structure data in the preset standard source database is added to the system object table.
[0018] Furthermore, the table type update is specifically as follows: using the thread to extract all system object tables in the target database to obtain a system object table set, determining the table type update type of the system object table set according to the table type information, and updating the system object table set according to the table type update type and the preset standard source database.
[0019] Furthermore, the table type update type of the system object table set is determined according to the table type information, and the system object table set is updated according to the table type update type and the preset standard source database. Specifically, the table type information and the system object table set are traversed, and when the table type information already exists in the system object table set, the table type update type is table type update, and the table type data in the preset standard source database is extracted, and the table type data replaces the pre-stored table type data in the system object table set; when the table type information does not exist in the system object table set, the table type update type is table type addition, and the table type data in the preset standard source database is added to the system object table.
[0020] Furthermore, the stored procedure update is specifically as follows: using the thread to extract all system object tables in the target database to obtain a system object table set, determining the stored procedure update type of the system object table set based on the stored procedure information, and updating the system object table set based on the stored procedure update type and the preset standard source database.
[0021] Furthermore, the stored procedure update type of the system object table set is determined based on the stored procedure information, and the system object table set is updated based on the stored procedure update type and the preset standard source database. Specifically, the stored procedure information and the system object table set are traversed; when the stored procedure information already exists in the system object table set, the stored procedure update type is stored procedure update, and the stored procedure data in the preset standard source database is extracted, and the stored procedure data replaces the pre-stored stored procedure data in the system object table set; when the stored procedure information does not exist in the system object table set, the stored procedure update type is stored procedure addition, and the stored procedure data in the preset standard source database is added to the system object table.
[0022] The second object of the present invention is achieved by the following technical solution:
[0023] An automated database updating system, comprising:
[0024] A configuration module, wherein the configuration module stores the update data in a preset standard source database according to preset update requirement information, and obtains configuration information required to be updated, wherein the configuration information includes data table structure information, table type information, storage process information, and basic data table information, and the update data includes data table structure data, table type data, storage process data, and basic data table data;
[0025] A configuration reader, the configuration reader is used to read the configuration information and generate an update instruction containing the data table structure information, the table type, the stored procedure and the basic data table information according to the configuration information;
[0026] An instruction analyzer, the instruction analyzer is used to monitor the update instruction in the configuration reader and create a thread according to the update instruction;
[0027] An instruction executor is used to update the target database using the thread according to the update instruction and the preset standard source database.
[0028] Compared with the prior art, the beneficial effect of the present invention is as follows: an automated database update method of the present invention includes: storing update data in a preset standard source database according to preset update requirement information, obtaining configuration information of the required update, wherein the configuration information includes data table structure information, table type information, storage process information and basic data table information, and the update data includes data table structure data, table type data, storage process data and basic data table data; reading the configuration information, and generating an update instruction containing the data table structure information, the table type information, the storage process information and the basic data table information according to the configuration information; monitoring the update instruction in the configuration reader, and creating a thread according to the update instruction; and updating the target database using the thread according to the update instruction and the preset standard source database. By reading the update instruction and updating the target database according to the update instruction and the preset standard source database, manual update is not required, errors caused by manual update are avoided, the update rate is improved, and the labor input cost is reduced.
[0029] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention and implement it according to the contents of the specification, the following is a detailed description of the preferred embodiments of the present invention in conjunction with the accompanying drawings. The specific implementation of the present invention is given in detail by the following embodiments and their accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0031] Figure 1 A schematic diagram of a flow chart of an automated database updating method of the present invention;
[0032] Figure 2 This is a schematic diagram of the information flow during the working process of an automated database update system. DETAILED DESCRIPTION
[0033] The present invention is further described below in conjunction with the accompanying drawings and specific implementation methods. It should be noted that, under the premise of no conflict, the various embodiments or technical features described below can be arbitrarily combined to form a new embodiment.
[0034] like Figure 1 As shown, an automatic database updating method of the present invention comprises the following steps:
[0035] Step S1: store the update data in a preset standard source database according to preset update requirement information, and obtain configuration information of the required update, wherein the configuration information includes data table structure information, table type information, storage process information and basic data table information, and the update data includes data table structure data, table type data, storage process data and basic data table data;
[0036] Step S2, reading configuration information, and generating an update instruction containing data table structure information, table type information, storage process information and basic data table information according to the configuration information;
[0037] Step S3, listen to the update instruction, and create a thread according to the update instruction; in this implementation, each thread is the execution object of the update, each thread can correspond to one target database, and each thread can also correspond to two different target databases.
[0038] Step S4: According to the update instruction and the preset standard source database, the source database uses the thread to update the target database. Step S4 is specifically as follows:
[0039] Data table structure update, according to the data table structure information and the preset standard source database, the target database is updated by using threads. In this embodiment, specifically: all system object tables (i.e., SysObject tables) in the target database are extracted by using threads, specifically, all system object tables and Column data (column data) in the system object tables are extracted to obtain a system object table set. The target database in this embodiment is a Master database. The data table structure update type of the system object table set is determined according to the data table structure information. The system object table set is updated according to the data table structure update type and the preset standard source database. That is, when the data table structure information already exists in the system object table set, the data table structure update type is data table structure update, then the data table structure data in the preset standard source database is extracted, and the data table structure data in the system object table set is replaced by the pre-stored data table structure data; when the data table structure information does not exist in the system object table set, the data table structure update type is data table structure addition, and the data table structure data in the preset standard source database is added to the system object table.
[0040] Table type update, according to the table type information and the preset standard source database, the target database is updated using threads. Specifically: all system object tables (i.e. SysObject tables) in the target database are extracted using threads, specifically all system object tables and Column data (column data) in the system object tables are extracted to obtain a system object table set. The target database in this embodiment is a Master database, and the table type update type of the system object table set is determined according to the table type information. The system object table set is updated according to the table type update type and the preset standard source database, that is, the table type information and the system object table set are traversed. When the table type information already exists in the system object table set, the table type update type is table type update, and the table type data in the preset standard source database is extracted, and the table type data replaces the pre-stored table type data in the system object table set; when the table type information does not exist in the system object table set, the table type update type is table type addition, and the table type data in the preset standard source database is added to the system object table.
[0041] Stored procedure update, based on the stored procedure information and the preset standard source database, the target database is updated using threads. Specifically, all system object tables (i.e., SysObject tables) in the target database are extracted using threads, specifically, all system object tables and Column data (column data) in the system object tables are extracted to obtain a system object table set. The target database in this embodiment is a Master database, and the system object table set is updated according to the stored procedure update type and the preset standard source database, that is, the stored procedure information and the system object table set are traversed. When the stored procedure information already exists in the system object table set, the stored procedure update type is a stored procedure update, and the stored procedure data in the preset standard source database is extracted, and the stored procedure data replaces the pre-stored stored procedure data in the system object table set; when the stored procedure information does not exist in the system object table set, the stored procedure update type is a stored procedure addition, and the stored procedure data in the preset standard source database is added to the system object table.
[0042] Basic data table update, based on the basic data table information and the preset standard source database, the target database is updated using threads. Specifically: based on the basic data table information and the preset standard source database, the target database is updated using threads, that is, the basic data table data in the preset standard database is extracted, and the preset basic data table in the target database is compared with the basic data table information. If the same is found, the preset basic data table is replaced with the basic data table data; if it needs to be added, the basic data table data is added to the preset basic data table.
[0043] like Figure 2 As shown, an automated database update system of the present invention includes a configuration module, which stores update data to a preset standard source database according to preset update requirement information, and obtains configuration information for the required update, wherein the configuration information includes data table structure information, table type information, storage process and basic data table information, and the update data includes data table structure data, table type data, storage process data and basic data table data; a configuration reader, which is used to read the configuration information and generate update instructions containing data table structure information, table type information, storage process information and basic data table information according to the configuration information; an instruction analyzer, which is used to listen to the update instructions in the configuration reader and create threads according to the update instructions; an instruction executor, which is used to update the target database using threads according to the update instructions and the preset standard source database. The specific working process has been described in detail in the above method and will not be repeated here.
[0044] An automated database update method of the present invention includes: storing update data in a preset standard source database according to preset update requirement information, obtaining configuration information of the required update, wherein the configuration information includes data table structure information, table type information, storage process information and basic data table information, and the update data includes data table structure data, table type data, storage process data and basic data table data; reading the configuration information, and generating update instructions containing data table structure information, table type information, storage process information and basic data table information according to the configuration information; monitoring the update instructions in the configuration reader, and creating threads according to the update instructions; and using threads to update the target database according to the update instructions and the preset standard source database. By reading the update instructions and updating the target database according to the update instructions and the preset standard source database, manual update is not required, errors caused by manual update are avoided, the update rate is improved, and the labor input cost is reduced.
[0045] The above are only preferred embodiments of the present invention and are not intended to limit the present invention in any form. Any ordinary technician in the industry can smoothly implement the present invention as shown in the drawings and above. However, any equivalent changes, modifications and evolutions made by technicians familiar with the profession without departing from the scope of the technical solution of the present invention using the technical content disclosed above are all equivalent embodiments of the present invention. At the same time, any equivalent changes, modifications and evolutions made to the above embodiments based on the essential technology of the present invention are still within the protection scope of the technical solution of the present invention.
Claims
1. An automated database updating method, characterized in that: The following steps are involved: Step S1, storing the update data in a preset standard source database according to preset update requirement information, and obtaining configuration information of the required update, wherein the configuration information includes data table structure information, table type information, storage process information and basic data table information, and the update data includes data table structure data, table type data, storage process data and basic data table data; Step S2, reading the configuration information, and generating an update instruction containing the data table structure information, the table type information, the storage process information and the basic data table information according to the configuration information; Step S3, monitoring the update instruction, and creating a thread according to the update instruction; Step S4, using the thread to update the target database according to the update instruction and the preset standard source database; The step S4 is specifically as follows: Data table structure update, according to the data table structure information and the preset standard source database, the target database is updated by using threads, specifically: all system object tables in the target database, namely SysObject tables, are extracted by using threads, specifically all system object tables and Column data in the system object tables are extracted to obtain a system object table set, the target database is a Master database, the data table structure update type of the system object table set is determined according to the data table structure information, the system object table set is updated according to the data table structure update type and the preset standard source database, that is, when the data table structure information already exists in the system object table set, the data table structure update type is data table structure update, then the data table structure data in the preset standard source database is extracted, and the data table structure data in the system object table set is replaced by the pre-stored data table structure data; when the data table structure information does not exist in the system object table set, the data table structure update type is data table structure addition, and the data table structure data in the preset standard source database is added to the system object table; Table type update, according to the table type information and the preset standard source database, the target database is updated by using threads, all system object tables in the target database are extracted by using threads, all system object tables and Column data in the system object tables are extracted, and a system object table set is obtained. The target database is a Master database, and the table type update type of the system object table set is determined according to the table type information, and the system object table set is updated according to the table type update type and the preset standard source database, that is, the table type information and the system object table set are traversed. When the table type information already exists in the system object table set, the table type update type is table type update, and the table type data in the preset standard source database is extracted, and the table type data replaces the pre-stored table type data in the system object table set; when the table type information does not exist in the system object table set, the table type update type is table type addition, and the table type data in the preset standard source database is added to the system object table; Stored procedure update: According to the stored procedure information and the preset standard source database, the target database is updated using threads. All system object tables in the target database are extracted using threads. Specifically, all system object tables and Column data in the system object tables are extracted to obtain a system object table set. The target database is a Master database. According to the stored procedure update type and the preset standard source database, the system object table set is updated, that is, the stored procedure information and the system object table set are traversed. When the stored procedure information already exists in the system object table set, the stored procedure update type is stored procedure update, and the stored procedure data in the preset standard source database is extracted, and the stored procedure data replaces the pre-stored stored procedure data in the system object table set; when the stored procedure information does not exist in the system object table set, the stored procedure update type is stored procedure addition, and the stored procedure data in the preset standard source database is added to the system object table; Update the basic data table, and use threads to update the target database according to the basic data table information and the preset standard source database. Update the target database according to the basic data table information and the preset standard source database, that is, preset the basic data table data in the standard database, and extract the preset basic data table in the target database, compare the preset basic data table with the basic data table information, if they are found to be the same, use the basic data table data to replace the preset basic data table; if it needs to be added, add the basic data table data to the preset basic data table.
2. An automated database updating system, characterized in that: The method for implementing the automated database update of claim 1 comprises: A configuration module, wherein the configuration module stores the update data in a preset standard source database according to preset update requirement information, and obtains configuration information required to be updated, wherein the configuration information includes data table structure information, table type information, storage process information, and basic data table information, and the update data includes data table structure data, table type data, storage process data, and basic data table data; A configuration reader, the configuration reader is used to read the configuration information and generate an update instruction containing the data table structure information, the table type information, the storage process information and the basic data table information according to the configuration information; An instruction analyzer, the instruction analyzer is used to monitor the update instruction in the configuration reader and create a thread according to the update instruction; An instruction executor is used to update the target database using the thread according to the update instruction and the preset standard source database.
