Disclosure of Invention
In view of this, the present invention provides a database modification method and an application server, which can evaluate the risk of modification before modifying a database object and before it is clear that the dependency of the object to be modified and other objects is complex, and finally determine whether to modify the corresponding object. Therefore, the safety of the database is ensured, and the ordinary maintenance process of the database is simplified.
First, to achieve the above object, the present invention provides an application server, where the application server includes a memory, a processor, and a database modification program stored in the memory and executable on the processor, and the database modification program implements the following steps when executed by the processor:
analyzing a database, and acquiring an implementation program of each object in the database;
calculating the complexity of each object associated with other objects through the implementation program of each object;
judging whether the complexity of the association between the target object and the other objects exceeds a preset value or not; and
and when the complexity of the association between the target object and the other objects does not exceed the preset value, controlling the target object to be in a modifiable state in the database.
Optionally, the database modification program further implements the following steps when executed by the processor:
and when the complexity of the association between the target object and the other objects exceeds the preset value, outputting prompt information aiming at the preset position of the target object in the database.
Optionally, the database modification program further implements the following steps when executed by the processor:
and when the complexity of the association between the target object and the other objects exceeds the preset value, prompting the risk of the target object in the database when the target object is modified.
Optionally, the step of controlling the target object to be in a modifiable state in the database specifically includes:
setting the modifiable state to a text entry state, an
When the object is in the text entry state, the database may accept user modifications to the object.
Optionally, the step of calculating, by the implementation program of each object, the complexity of each object associated with other objects specifically includes:
analyzing a function required for realizing each object, and analyzing an object called by the function;
recording the times of calling each object by the function; and
the degree is determined as the complexity of the respective function in relation to other functions.
In addition, to achieve the above object, the present invention further provides a database modification method, which is applied to an application server, and the method includes:
analyzing a database, and acquiring an implementation program of each object in the database;
calculating the complexity of each object associated with other objects through the implementation program of each object;
judging whether the complexity of the association between the target object and the other objects exceeds a preset value or not; and
and when the complexity of the association between the target object and the other objects does not exceed the preset value, controlling the target object to be in a modifiable state in the database.
Optionally, the method further comprises:
and when the complexity of the association between the target object and the other objects exceeds the preset value, outputting prompt information aiming at the preset position of the target object in the database.
Optionally, the method further comprises:
and when the complexity of the association between the target object and the other objects exceeds the preset value, prompting the risk of the target object in the database when the target object is modified.
Optionally, the step of controlling the target object to be in a modifiable state in the database specifically includes:
setting the modifiable state to a text entry state, an
When the object is in the text entry state, the database may accept user modifications to the object.
Optionally, the step of calculating, by the implementation program of each object, the complexity of each object associated with other objects specifically includes:
analyzing a function required for realizing each object, and analyzing an object called by the function;
recording the times of calling each object by the function; and
the degree is determined as the complexity of the respective function in relation to other functions.
Further, to achieve the above object, the present invention also provides a computer-readable storage medium storing a database modification program, which is executable by at least one processor to cause the at least one processor to perform the steps of the database modification method as described above.
Compared with the prior art, the application server, the database modification method and the computer-readable storage medium provided by the invention have the advantages that firstly, the database is analyzed, and the implementation program of each object in the database is obtained; secondly, calculating the complexity of each object associated with other objects through the implementation program of each object; and finally, when the complexity of the association between the target object and the other objects does not exceed a preset value, controlling the target object to be in a modifiable state in the database. Therefore, the defect that the whole database is crashed to cause serious data loss due to the fact that certain objects in the database are modified blindly can be avoided, the complexity degree of the dependency of the objects to be modified and other objects can not be determined before the objects of the database are modified, the modification risk of the objects can be further evaluated, and whether the corresponding objects are modified or not can be finally determined. Therefore, the safety of the database is ensured, and the ordinary maintenance process of the database is simplified.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the description relating to "first", "second", etc. in the present invention is for descriptive purposes only and is not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present invention.
Fig. 1 is a schematic diagram of an alternative hardware architecture of the application server 1.
The application server 1 may be a rack server, a blade server, a tower server, or a rack server, and the application server 1 may be an independent server or a server cluster composed of a plurality of servers.
In this embodiment, the application server 1 may include, but is not limited to, a memory 11, a processor 12, and a network interface 13, which may be communicatively connected to each other through a system bus.
The application server 1 is connected to the network through a network interface 13 to acquire information. The network may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a Global system of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth (Bluetooth), Wi-Fi, or a communication network.
It is noted that fig. 1 only shows the application server 1 with components 11-13, but it is to be understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead.
The memory 11 includes at least one type of readable storage medium, which includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage 11 may be an internal storage unit of the application server 1, such as a hard disk or a memory of the application server 1. In other embodiments, the memory 11 may also be an external storage device of the application server 1, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like equipped in the application server 1. Of course, the memory 11 may also comprise both an internal storage unit of the application server 1 and an external storage device thereof. In this embodiment, the memory 11 is generally used for storing an operating system installed in the application server 1 and various types of application software, such as the program code of thedatabase modification program 200. Furthermore, the memory 11 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 12 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 12 is generally used for controlling the overall operation of the application server 1, such as performing data interaction or communication related control and processing. In this embodiment, the processor 12 is configured to run the program code stored in the memory 11 or process data, for example, run thedatabase modification program 200.
The network interface 13 may comprise a wireless network interface or a wired network interface, and the network interface 13 is generally used for establishing communication connection between the application server 1 and other electronic devices.
In this embodiment, when thedatabase modification program 200 is installed and operated in the application server 1, and when thedatabase modification program 200 is operated, the application server 1 analyzes the database to obtain the implementation program of each object in the database; calculating the complexity of each object associated with other objects through the implementation program of each object; judging whether the complexity of the association between the target object and the other objects exceeds a preset value or not; and when the complexity of the association between the target object and the other objects does not exceed the preset value, controlling the target object to be in a modifiable state in the database. Therefore, the defect that the whole database is crashed to cause serious data loss due to the fact that certain objects in the database are modified blindly can be avoided, the complexity degree of the dependency of the objects to be modified and other objects can not be determined before the objects of the database are modified, the modification risk of the objects can be further evaluated, and whether the corresponding objects are modified or not can be finally determined. Therefore, the safety of the database is ensured, and the ordinary maintenance process of the database is simplified.
The hardware structure and functions of the related devices of the various embodiments of the present invention have been described in detail so far. Hereinafter, various embodiments of the present invention will be proposed based on the above-described application environment and related devices.
First, the present invention provides adatabase modification program 200.
Referring to fig. 2, a block diagram of adatabase modification program 200 according to a first embodiment of the present invention is shown.
In this embodiment, thedatabase modification program 200 includes a series of computer program instructions stored in the memory 11, which when executed by the processor 12, can implement the database modification operations of the embodiments of the present invention. In some embodiments,database modification program 200 may be divided into one or more modules based on the particular operations implemented by the portions of the computer program instructions. For example, in fig. 2, thedatabase modification program 200 may be divided into an analysis module 201, a calculation module 202, a judgment module 203, and a control module 204. Wherein:
the analysis module 201 is configured to analyze a database, and obtain an implementation program of each object in the database. Specifically, the implementation program includes each function of the implementation object. In this embodiment, the object includes at least one of a view, a stored procedure, and a table.
The calculating module 202 is configured to calculate, by the implementation program of each object, the complexity of each object associated with other objects.
The judging module 203 is configured to judge whether the complexity of the association between the target object and the other objects exceeds a preset value.
The control module 204 is configured to control the target object to be in a modifiable state in the database when the complexity of the association between the target object and the other objects does not exceed the preset value.
Specifically, the control module 204 sets the modifiable state to a text entry state, and the database can accept user modifications to the target object when the object is in the text entry state.
Further, the control module 204 is further configured to output prompt information for a preset position of the target object in the database when the complexity of the association between the target object and the other objects exceeds the preset value.
In this embodiment, when the degree of association between the target object and another object exceeds the preset value, it indicates that the degree of dependency between the object and the other object is high, and once the object is modified, the object may be changed by another object, which may cause a change in the entire database. Or in other embodiments, for such objects whose association degree with other objects exceeds a preset value, the control module 204 controls the database to present an uneditable state to the objects, so as to actively cut off the possibility of modifying the objects by the user, or prompt the risk degree, and the user evaluates whether to modify the objects according to actual needs.
Further, the control module 204 is further configured to prompt a risk existing when the target object is modified in the database when the complexity of the association between the target object and the other objects exceeds the preset value.
Specifically, when the complexity of the association between the target object and the other objects exceeds a preset value, the object is in a high risk state or a low risk state when modified in the database. The control module 204 prompts the risk degree, and the user evaluates whether to modify the risk degree according to actual needs.
Through the program module 201 and 204, thedatabase modification program 200 provided by the invention firstly analyzes the database to obtain the implementation program of each object in the database; secondly, calculating the complexity of each object associated with other objects through the implementation program of each object; then, judging whether the complexity of the target object and the other objects exceeds a preset value; and finally, when the complexity of the association between the target object and the other objects does not exceed the preset value, controlling the target object to be in a modifiable state in the database. Therefore, the defect that the whole database is crashed to cause serious data loss due to the fact that certain objects in the database are modified blindly can be avoided, the complexity degree of the dependency of the objects to be modified and other objects can not be determined before the objects of the database are modified, the modification risk of the objects can be further evaluated, and whether the corresponding objects are modified or not can be finally determined. Therefore, the safety of the database is ensured, and the ordinary maintenance process of the database is simplified.
Further, a second embodiment of the present invention (as shown in fig. 3) is proposed based on the above-described first embodiment of thedatabase modification program 200 of the present invention. In this embodiment, thedatabase modification program 200 further includes a recording module 205.
In this embodiment, the parsing module 201 is further configured to analyze a function required for implementing each object, and parse an object called by the function.
The recording module 205 is configured to record the number of times that each object is called by a function, and determine the number of times as the complexity of the corresponding function associated with other functions.
The following is a specific example:
for example, the object is a table, the implementation program for implementing the table includes at least one function, and the table is finally implemented through the invocation of such a function. Then in the function of the implementation table, 1 view is called, and 1 storage process is called; similarly, in the implementation process of the object of the storage process, the corresponding function calls a table for 3 times and a view for 2 times; in the implementation process of the view object, the corresponding function calls 4 times of tables and 3 times of storage processes. Then in the above database implementation, the storage process is called 4 times by other objects, the table is called 7 times by other objects, and the view is called 3 times by other objects. The complexity of the association of the three objects of the view, the stored procedure and the table with other objects can be determined to be 3, 4 and 7 respectively, which indicates that the table is most associated with other objects and the modification is most easy to change in the whole database. In this embodiment, the preset value may be set according to the needs of the user, or may be an average value of the complexity of all objects associated with other objects.
Through the program module 201 and 205, thedatabase modification program 200 provided by the present invention can calculate the complexity of each object associated with other objects through the implementation program of each object.
In addition, the invention also provides a database modification method.
Fig. 4 is a flow chart showing a first embodiment of the database modification method according to the present invention. In this embodiment, the execution order of the steps in the flowchart shown in fig. 4 may be changed and some steps may be omitted according to different requirements.
Step S401, analyzing the database, and acquiring the implementation program of each object in the database. Specifically, the implementation program includes each function of the implementation object. In this embodiment, the object includes at least one of a view, a stored procedure, and a table.
Step S402, calculating the complexity of each object associated with other objects by the implementation program of each object. Specifically, the specific steps of calculating the complexity of each object associated with other objects through the implementation program of each object will be described in detail in a third embodiment (see fig. 6) of the database modification method according to the present invention.
Step S403, determining whether the complexity of the target object associated with the other objects exceeds a preset value. And executing step S404 when the complexity of the association between the target object and the other objects does not exceed the preset value, and otherwise executing step S405 when the complexity of the association between the target object and the other objects exceeds the preset value.
Step S404, controlling the target object to be in a modifiable state in the database.
Specifically, the application server 1 sets the modifiable state as a text input state, and when the object is in the text input state, the database can accept the modification of the target object by the user.
Step S405, outputting prompt information aiming at the preset position of the target object in the database.
In this embodiment, when the degree of association between the target object and another object exceeds the preset value, it indicates that the degree of dependency between the object and the other object is high, and once the object is modified, the object may be changed by another object, which may cause a change in the entire database. Or in other embodiments, for such objects whose association degree with other objects exceeds a preset value, the application server 1 controls the database to present an uneditable state to the objects, so as to actively cut off the possibility of modifying the objects by the user, or prompt the risk degree, and the user evaluates whether to modify the objects according to actual needs.
Through the steps S401-405, the database modification method provided by the invention comprises the steps of firstly analyzing the database and acquiring the implementation program of each object in the database; secondly, calculating the complexity of each object associated with other objects through the implementation program of each object; and finally, when the complexity of the association between the target object and the other objects does not exceed a preset value, controlling the target object to be in a modifiable state in the database. Therefore, the defect that the whole database is crashed to cause serious data loss due to the fact that certain objects in the database are modified blindly can be avoided, the complexity degree of the dependency of the objects to be modified and other objects can not be determined before the objects of the database are modified, the modification risk of the objects can be further evaluated, and whether the corresponding objects are modified or not can be finally determined. Therefore, the safety of the database is ensured, and the ordinary maintenance process of the database is simplified.
Fig. 5 is a flow chart of a second embodiment of the database modification method according to the present invention. In this embodiment, the execution order of the steps in the flowchart shown in fig. 5 may be changed and some steps may be omitted according to different requirements.
Step S501, analyzing a database, and acquiring an implementation program of each object in the database. Specifically, the implementation program includes each function of the implementation object. In this embodiment, the object includes at least one of a view, a stored procedure, and a table.
Step S502, calculating the complexity of each object associated with other objects by the implementation program of each object.
Step S503, determining whether the complexity of the target object associated with the other objects exceeds a preset value. And executing step S504 when the complexity of the association between the target object and the other objects does not exceed the preset value, and otherwise executing step S505 when the complexity of the association between the target object and the other objects exceeds the preset value.
Step S504, controlling the target object to be in a modifiable state in the database.
And step S505, prompting the risk of the target object when the target object is modified in the database.
Specifically, when the complexity of the association between the target object and the other objects exceeds a preset value, the object is in a high risk state or a low risk state when modified in the database. The application server 1 prompts the risk degree, and the user evaluates whether to modify the risk degree according to actual needs.
Through the steps S501 to S505, the database modification method provided by the present invention can evaluate the risk of modification without determining the complexity of the dependency between the object to be modified and other objects, and finally determine whether to modify the corresponding object. Therefore, the safety of the database is ensured, and the ordinary maintenance process of the database is simplified.
Fig. 6 is a flow chart of a third embodiment of the database modification method according to the present invention. In this embodiment, the step of calculating the complexity associated with each object and other objects through the implementation program of each object specifically includes:
step S601, analyzing a function required for implementing each object, and analyzing an object called by the function.
Step S602, records the number of times each object is called by the function.
Step S603, determining the number of times as the complexity of the corresponding function associated with other functions.
The following is a specific example:
for example, the object is a table, the implementation program for implementing the table includes at least one function, and the table is finally implemented through the invocation of such a function. Then in the function of the implementation table, 1 view is called, and 1 storage process is called; similarly, in the implementation process of the object of the storage process, the corresponding function calls a table for 3 times and a view for 2 times; in the implementation process of the view object, the corresponding function calls 4 times of tables and 3 times of storage processes. Then in the above database implementation, the storage process is called 4 times by other objects, the table is called 7 times by other objects, and the view is called 3 times by other objects. The complexity of the association of the three objects of the view, the stored procedure and the table with other objects can be determined to be 3, 4 and 7 respectively, which indicates that the table is most associated with other objects and the modification is most easy to change in the whole database. In this embodiment, the preset value may be set according to the needs of the user, or may be an average value of the complexity of all objects associated with other objects.
Through the steps S601 to S603, the database modification method provided by the present invention can calculate the complexity of each object associated with other objects through the implementation program of each object.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.