Disclosure of Invention
The invention aims to provide a database changing method, a database changing device and a storage medium, so as to relatively ensure the changing efficiency of a database and the stability of network service work.
To solve the above technical problem, the present invention provides a database changing method, including:
acquiring an original data table in a database to the local;
performing attribute change operation on the local original data table according to the attribute change information and generating a local data table;
acquiring state information generated in the process of changing operation;
judging whether the state information does not contain a field for representing attribute change operation abnormity;
if yes, performing attribute change operation on the original data table in the database according to the attribute change information.
Preferably, the obtaining the original data table in the database to the local includes:
acquiring an original data table in a database to the local according to a data read-write request transmitted by a network service;
after performing the attribute change operation on the local original data table according to the attribute change information and generating the local data table, the method further includes:
and performing read-write operation on the local data table according to the data read-write request, and returning operation result information to the network service.
Preferably, when the data read-write request is a data read request, performing read-write operation on the local data table according to the data read-write request, and returning operation result information to the network service, including:
and reading the target data in the local data table according to the data reading request, and returning the target data serving as operation result information to the network service.
Preferably, when the data read-write request is a data write request, performing read-write operation on the local data table according to the data read-write request, and returning operation result information to the network service, including:
acquiring data to be written according to the data writing request;
judging whether the attribute of the data to be written in the local data table is consistent with the attribute of the data to be written in the original data table;
if so, storing the data to be written into the database, and returning the operation result information to the network service;
otherwise, storing the data to be written to the local and returning the operation result information to the network service.
Preferably, before performing the attribute change operation on the original data table in the database according to the attribute change information, the method further includes:
judging whether an original data table in a database is not accessed;
if yes, executing the step of performing attribute change operation on the original data table in the database according to the attribute change information.
Preferably, the attribute change information includes one or more of field addition information, field modification information, and field deletion information.
In addition, the present invention also provides a database changing apparatus, comprising:
the local acquisition module is used for acquiring the original data table in the database to the local;
the data table generating module is used for carrying out attribute change operation on the local original data table according to the attribute change information and generating a local data table;
the state acquisition module is used for acquiring state information generated in the change operation process;
the state judgment module is used for judging whether the state information does not contain a field for representing the abnormal attribute change operation, and if so, the attribute change module is called;
and the attribute changing module is used for carrying out attribute changing operation on the original data table in the database according to the attribute changing information.
Preferably, the local acquisition module includes:
the request acquisition module is used for acquiring an original data table in the database to the local according to a data read-write request transmitted by the network service;
the device still includes:
and the read-write execution module is used for performing read-write operation on the local data table according to the data read-write request and returning operation result information to the network service.
In addition, the present invention also provides a database changing apparatus, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the database modification method when executing the computer program.
Furthermore, the present invention also provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, realizes the steps of the database changing method as described above.
The method for changing the database comprises the steps of firstly obtaining an original data table in the database to the local, further carrying out attribute changing operation on the local original data table according to attribute changing information to generate a local data table, further obtaining state information generated in the changing operation process, further judging whether the state information contains related contents representing that the attribute changing operation is abnormal or not, and if the attribute changing operation process is not abnormal, further carrying out attribute changing operation on the original data table in the database according to the attribute changing information. Before a certain attribute change operation is carried out on a data table in a database, the data table in the database is firstly acquired to local equipment for carrying out the attribute change operation, and then the attribute change operation is executed on the data table in the database only when the attribute change operation is normally executed in the local equipment, so that the attribute of the data table in the database can be ensured to be normally changed, the conditions that the change of the database is backed off and the data table cannot normally provide data support for network service after the change are avoided, and the change efficiency of the database and the working stability of the network service are relatively ensured. In addition, the invention also provides a database changing device, equipment and a storage medium, and the beneficial effects are as above.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without any creative work belong to the protection scope of the present invention.
At present, after a network service is released, if the attribute of a data table in a database needs to be changed, a technician often performs a change operation on the attribute of the data table according to a change requirement, but because the number of the data tables in the database is huge, the technician often cannot completely and accurately change the attribute of the data table, so that the database may not normally provide data support for the network service through the changed data table, and further needs to back the change of the database, and the change efficiency of the database and the working stability of the network service are difficult to ensure.
Therefore, the core of the invention is to provide a database changing method to relatively ensure the changing efficiency of the database and the stability of the network service operation. The other core of the invention is to provide a database changing device, equipment and a storage medium.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
Fig. 1 is a flowchart of a database changing method according to an embodiment of the present invention. Referring to fig. 1, the specific steps of the database changing method include:
step S10: and acquiring the original data table in the database to the local.
It should be noted that the execution main body in this embodiment may be a middleware device in a communication connection relationship with the database, and is used to respond to an attribute change requirement of a technician for a data table in the database, perform the same change on the locally acquired data table in the middleware device locally, and perform the attribute change on the data table in the database according to the attribute change requirement after the operation of changing the locally acquired data table is normally performed.
The database in this step is the database that needs to be subjected to attribute modification in this embodiment, and the attribute modification of the database is essentially to modify the attributes in the data tables in the database, and this step is mainly focused on acquiring the original data tables in the database to the local, that is, this embodiment performs subsequent operations on the basis of acquiring the original data tables in the database to the local.
Step S11: and performing attribute change operation on the local original data table according to the attribute change information and generating a local data table.
The attribute change information in this step is a change instruction according to which the attribute of the original data sheet is changed, and the change operation of the attribute in the data sheet can be realized by executing the change instruction in the attribute change information. The change information of the attribute may further include the contents of one or more of field addition information, field modification information, and field deletion information, i.e., an instruction to add a new field in the data table, an instruction to modify the type or length of an existing field in the data table, and an instruction to delete an existing field in the data table. The attribute change information in this step may be set locally in advance by a technician in the form of a configuration file, or may be initiated by the technician in real time according to actual needs.
Step S12: state information generated during the change operation is obtained.
After performing the attribute change operation on the local original data table according to the attribute change information and generating the local data table, the present step further obtains status information generated during the change operation performed on the original data table according to the attribute change information, where the status information represents an overall operating status of the local system when the change operation is performed on the original data table.
Step S13: it is determined whether the status information does not include a field indicating that the attribute changing operation is abnormal, and if so, step S14 is executed.
Step S14: and performing attribute change operation on the original data table in the database according to the attribute change information.
After state information generated in the process of changing operation is acquired, whether the state information contains a field representing abnormal attribute changing operation is further judged, the content of the field in the state information comprises a state code field, a keyword field and the like, if the state information does not contain the field representing abnormal attribute changing operation, the attribute changing operation performed on an original data table in the local place is normally performed, in this case, the attribute changing operation can be considered to be normally performed on the original data table in the database, and therefore the attribute changing operation is further performed on the original data table in the database according to the attribute changing information.
In addition, on the basis of the above embodiment, as a preferred implementation, before performing the attribute change operation on the original data table in the database according to the attribute change information, the method further includes:
judging whether an original data table in a database is not accessed;
if yes, executing the step of performing attribute change operation on the original data table in the database according to the attribute change information.
It should be noted that, in the present embodiment, before performing the attribute change operation on the original data table in the database according to the attribute change information, it is determined whether the original data table in the database is not accessed, and if so, it is determined that the content of the data in the original data table in the database is not changed, and on this basis, the step of performing the attribute change operation on the original data table in the database according to the attribute change information is performed, so as to avoid a situation that the data written or modified in the original data table is lost or damaged due to the attribute change of the original data table, and relatively ensure the integrity and accuracy of the data in the database when performing the attribute change operation on the original data table in the database.
The method for changing the database comprises the steps of firstly obtaining an original data table in the database to the local, further carrying out attribute changing operation on the local original data table according to attribute changing information to generate a local data table, further obtaining state information generated in the changing operation process, further judging whether the state information contains related contents representing that the attribute changing operation is abnormal or not, and if the attribute changing operation process is not abnormal, further carrying out attribute changing operation on the original data table in the database according to the attribute changing information. Before a certain attribute change operation is carried out on a data table in a database, the data table in the database is firstly acquired to local equipment for carrying out the attribute change operation, and then the attribute change operation is executed on the data table in the database only when the attribute change operation is normally executed in the local equipment, so that the attribute of the data table in the database can be ensured to be normally changed, the conditions that the change of the database is backed off and the data table cannot normally provide data support for network service after the change are avoided, and the change efficiency of the database and the working stability of the network service are relatively ensured.
Fig. 2 is a flowchart of a database changing method according to an embodiment of the present invention. Referring to fig. 2, the specific steps of the database changing method include:
step S20: and acquiring an original data table in the database to the local according to a data read-write request transmitted by the network service.
Step S21: and performing attribute change operation on the local original data table according to the attribute change information and generating a local data table.
Step S22: and performing read-write operation on the local data table according to the data read-write request, and returning operation result information to the network service.
Step S23: state information generated during the change operation is obtained.
Step S24: it is determined whether the status information does not include a field indicating that the attribute changing operation is abnormal, and if so, step S25 is executed.
Step S25: and performing attribute change operation on the original data table in the database according to the attribute change information.
It should be noted that, in this embodiment, the middleware device receives a data read-write request incoming from the network service, and further obtains the original data table in the database to the local according to the data read-write request incoming from the network service, that is, in this step, the corresponding original data table is obtained to the local in the database based on the data read-write request of the network service. In the topology structure corresponding to the embodiment, the middleware device is established between the service device and the database, the service device initiates a data read-write request to the database through the middleware device, and after receiving the read-write request, the middleware device acquires an original data table in the database to the local according to the data read-write request transmitted by the network service, and further acquires a local data table according to the original data table, thereby further performing read-write operation on the local data table according to the data read-write request, and returning operation result information to the network service. Compared with the original data table, the local data table is subjected to the latest version of the data table with the changed attributes, so that the accuracy of the data provided for the network service can be ensured to the greatest extent.
On the basis of this embodiment, as a preferred implementation manner, when the data read-write request is a data read request, performing a read-write operation on the local data table according to the data read-write request, and returning operation result information to the network service, includes:
and reading the target data in the local data table according to the data reading request, and returning the target data serving as operation result information to the network service.
It should be noted that, when the data read-write request is a data read request, the corresponding target data in the local data table is read according to the data read request, and the target data is returned to the network service as an operation result, so as to provide the network service with the required data content, and relatively ensure the accuracy of the data content acquired by the network service through the middleware device.
In addition, as another preferred embodiment, when the data read-write request is a data write request, performing a read-write operation on the local data table according to the data read-write request, and returning operation result information to the network service, includes:
acquiring data to be written according to the data writing request;
judging whether the attribute of the data to be written in the local data table is consistent with the attribute of the data to be written in the original data table;
if so, storing the data to be written into the database, and returning the operation result information to the network service;
otherwise, storing the data to be written to the local and returning the operation result information to the network service.
It should be noted that, when the data read-write request is a data write request, the middleware device first obtains data to be written of the network service according to the data write request, and then determines whether the attribute of the data to be written in the local data table is consistent with the attribute of the data to be written in the original data table, if so, it indicates that the attribute of the data table corresponding to the data to be written is not changed, and therefore, stores the data to be written in the database, and returns the operation result information to the network service; if the data to be written is inconsistent with the data to be written, the attribute of the data table corresponding to the data to be written is changed, so that the data to be written is stored by taking the changed attribute as a storage standard, namely the data to be written is stored to the local of the middleware equipment, and the operation result information is returned to the network service, so that the accuracy of the data content stored by the network service through the middleware equipment is relatively ensured.
Fig. 3 is a structural diagram of a database modification apparatus according to an embodiment of the present invention. The database change device provided by the embodiment of the invention comprises:
a local obtaining module 10, configured to obtain an original data table in a database to a local;
the data table generating module 11 is configured to perform attribute change operation on a local original data table according to the attribute change information and generate a local data table;
a status acquisition module 12, configured to acquire status information generated during a change operation;
the state judging module 13 is used for judging whether the state information does not contain a field for representing the attribute change operation abnormity, and if so, the attribute changing module 14 is called;
and the attribute changing module 14 is used for performing attribute changing operation on the original data table in the database according to the attribute changing information.
The database changing device provided by the invention firstly acquires the original data table in the database to the local, then performs attribute changing operation on the local original data table according to the attribute changing information to generate the local data table, further acquires the state information generated in the changing operation process, further judges whether the state information contains related contents representing that the attribute changing operation is abnormal or not, and further performs attribute changing operation on the original data table in the database according to the attribute changing information if the attribute changing operation process is not abnormal. Before a certain attribute change operation is carried out on a data table in a database, the device firstly acquires the data table in the database to local equipment for carrying out the attribute change operation, and then executes the attribute change operation on the data table in the database only when the attribute change operation is normally executed in the local equipment, so that the attribute of the data table in the database can be ensured to be normally changed, the conditions that the change of the database is backed off and the data table cannot normally provide data support for network service after the change are avoided, and the change efficiency of the database and the stability of the network service work are relatively ensured.
In addition to the above database changing apparatus, as a preferred embodiment, the local acquiring module includes:
the request acquisition module is used for acquiring an original data table in the database to the local according to a data read-write request transmitted by the network service;
the device still includes:
and the read-write execution module is used for performing read-write operation on the local data table according to the data read-write request and returning operation result information to the network service.
The present invention also provides a database changing apparatus, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the database modification method when executing the computer program.
The database change device provided by the invention firstly acquires the original data table in the database to the local, then performs attribute change operation on the local original data table according to the attribute change information to generate the local data table, further acquires the state information generated in the change operation process, and further judges whether the state information contains related contents representing that the attribute change operation is abnormal or not, if the attribute change operation process is not abnormal, the attribute change operation is further performed on the original data table in the database according to the attribute change information. Before a certain attribute change operation is carried out on a data table in a database, the data table in the database is firstly acquired to the local equipment for carrying out the attribute change operation, and then the attribute change operation is executed on the data table in the database only when the attribute change operation is normally executed in the local equipment, so that the attribute of the data table in the database can be ensured to be normally changed, the conditions that the change of the database is backed off and the data table cannot normally provide data support for network service after the change are avoided, and the change efficiency of the database and the stability of the network service work are relatively ensured.
The present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the database modification method as described above.
The computer-readable storage medium provided by the invention firstly acquires the original data table in the database to the local, then performs attribute change operation on the local original data table according to the attribute change information to generate a local data table, further acquires the state information generated in the change operation process, further judges whether the state information contains related contents representing that the attribute change operation is abnormal or not, and further performs attribute change operation on the original data table in the database according to the attribute change information if the attribute change operation process is not abnormal. The computer readable storage medium acquires the data table in the database to the local device for attribute change operation before the data table in the database is subjected to the attribute change operation, and executes the attribute change operation on the data table in the database only when the attribute change operation is normally executed in the local device, so that the attribute of the data table in the database can be normally changed, the conditions that the change of the database is backed off and the data table cannot normally provide data support for network service after the change are avoided, and the change efficiency of the database and the stability of the network service work are relatively ensured.
The above description details a database modification method, apparatus, device and storage medium provided by the present invention. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.