CN109213748B - Database script file updating method, server and medium - Google Patents

Database script file updating method, server and medium Download PDF

Info

Publication number
CN109213748B
CN109213748B CN201810915165.XA CN201810915165A CN109213748B CN 109213748 B CN109213748 B CN 109213748B CN 201810915165 A CN201810915165 A CN 201810915165A CN 109213748 B CN109213748 B CN 109213748B
Authority
CN
China
Prior art keywords
database
script
database script
file
script file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810915165.XA
Other languages
Chinese (zh)
Other versions
CN109213748A (en
Inventor
陈文平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201810915165.XA priority Critical patent/CN109213748B/en
Publication of CN109213748A publication Critical patent/CN109213748A/en
Application granted granted Critical
Publication of CN109213748B publication Critical patent/CN109213748B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention is applicable to the technical field of computers, and provides a method, a server and a medium for updating a database script file, wherein the method comprises the following steps: receiving a file updating instruction; acquiring a database script in a target database script file; determining a first target database matched with the target database script file from deployed databases based on the unique identifier of the target database script file carried by the file updating instruction; generating a first database script file corresponding to a first target database based on a database object contained in the first target database and a preset database script generation strategy; and carrying out data analysis on the database scripts in the database script file, and if the database scripts in the target database script file are identical to the database scripts in the first database script file, storing the target database script file into a script library, so that the target database script file finally stored in the script library corresponds to the deployed corresponding database.

Description

Database script file updating method, server and medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method for updating a database script file, a server, and a computer readable storage medium.
Background
A database is an essential part of the system construction, and a database script is a collection of statements used to create database objects. Typically, when updating a created database, a database script used to create the database needs to be updated first. After the database script is updated, the new version of the database script is handed over to a test environment for testing the created database, and after the test is passed, the created database can be updated according to the new version of the database script. Meanwhile, after the database script is updated each time and passes the test, the database script synchronization tool synchronizes the latest version of the database script into the script library for replacing the old version of the database script.
The existing database script synchronization mechanism often has time delay, which can lead to the synchronization of a new version of database script to a script library before an old version of database script, so that the new version of database script can be covered by the old version of database script in the script library after the synchronization, and the database script finally stored in the script library is not corresponding to the database created based on the latest version of database script.
Disclosure of Invention
In view of this, the embodiments of the present invention provide a method, a server, and a computer readable storage medium for updating a database script file, so as to solve the problem that the existing database script synchronization mechanism has a delay, so that a database script finally stored in a script library does not correspond to a database created based on the latest version of the database script.
A first aspect of an embodiment of the present invention provides a method for updating a database script file, including:
receiving a file updating instruction for updating a database script file in a script library; the file updating instruction carries a unique identifier of a target database script file to be updated in the script library;
acquiring a database script in the target database script file;
determining a first target database matched with the target database script file from deployed databases based on the unique identification of the target database script file;
generating a first database script file corresponding to the first target database based on a database object contained in the first target database and a preset database script generation strategy;
And if the database script in the target database script file is completely the same as the database script in the first database script file, storing the target database script file into the script library.
A second aspect of an embodiment of the present invention provides a server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of:
receiving a file updating instruction for updating a database script file in a script library; the file updating instruction carries a unique identifier of a target database script file to be updated in the script library;
acquiring a database script in the target database script file;
determining a first target database matched with the target database script file from deployed databases based on the unique identification of the target database script file;
generating a first database script file corresponding to the first target database based on a database object contained in the first target database and a preset database script generation strategy;
And if the database script in the target database script file is completely the same as the database script in the first database script file, storing the target database script file into the script library.
A third aspect of the embodiments of the present invention provides a computer-readable storage medium storing a computer program which, when executed by a processor, performs the steps of:
receiving a file updating instruction for updating a database script file in a script library; the file updating instruction carries a unique identifier of a target database script file to be updated in the script library;
acquiring a database script in the target database script file;
determining a first target database matched with the target database script file from deployed databases based on the unique identification of the target database script file;
generating a first database script file corresponding to the first target database based on a database object contained in the first target database and a preset database script generation strategy;
and if the database script in the target database script file is completely the same as the database script in the first database script file, storing the target database script file into the script library.
The method, the server and the computer readable storage medium for updating the database script file provided by the embodiment of the invention have the following beneficial effects:
when a file updating instruction for updating a database script file in a script library is received, determining a first target database matched with a target database script file to be updated into the script library from deployed databases, converting the first target database into a first database script file corresponding to the first target database based on a preset database script generating strategy, carrying out data analysis on the database script in the database script file, and when the database script in the target database script file is completely identical with the database script in the first database script file, indicating that the target database script file corresponds to the deployed first target database, and storing the target database script file into the script library at the moment, thereby ensuring that the finally stored target database script file in the script library corresponds to the deployed corresponding database.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for updating a database script file according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a method for updating a database script file according to a second embodiment of the present invention;
FIG. 3 is a flowchart showing a specific implementation of S16 in a method for updating a database script file according to a third embodiment of the present invention;
FIG. 4 is a flowchart illustrating a method for updating a database script file according to a fourth embodiment of the present invention;
FIG. 5 is a flowchart illustrating a method for updating a database script file according to a fifth embodiment of the present invention;
FIG. 6 is a block diagram of a server according to an embodiment of the present invention;
fig. 7 is a block diagram of a server according to another embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating an implementation method of updating a database script file according to a first embodiment of the present invention. In this embodiment, the execution subject of the method for updating the database script file is a server. The method for updating the database script file shown in fig. 1 comprises the following steps:
S11: receiving a file updating instruction for updating a database script file in a script library; and the file updating instruction carries a unique identifier of the target database script file to be updated in the script library.
In the embodiment of the invention, the script library is used for storing database script files. The database script file is used for storing the database script, namely, the content in the database script file is the database script. The database script is a collection of sentences used for creating database objects, i.e. the server generates a corresponding database after executing the database script. Wherein the database objects include, but are not limited to: databases, data tables, indexes, views, triggers, functions, etc. Thus, database scripts generally include, but are not limited to, statements for building databases, data tables, stored procedures, triggers, and statements for data queries and custom functions. In practical application, the database script file is a file in text format. The format of the database script file corresponding to the different types of databases is different, for example, for the SQL Server database, the database script file is a text file with the file extension of "SQL".
In practical application, before the database is deployed to each database environment, the database script used for creating the database needs to be tested, the database is deployed based on the database script only after the test is passed, and meanwhile, the database script file used for storing the database script passed by the test is stored in the script library for recording. The database script test indicates that the database created based on the database script is correct and capable of functioning properly. It should be noted that, the script library stores a plurality of database script files for creating different databases respectively. The database script files used for creating different databases have different unique identifications, the database script files used for creating different versions of the same database have the same unique identification, and the database script files used for creating different versions of the same database can be distinguished by version information. In practical applications, the unique identifier of the database script file may be the name of the database created based on the database script in the database script file. For example, if the name of a database created based on a database script in a certain database script file is "product information library", the unique identifier of the database script file may be "product information library", i.e., the database script file may be named based on "product information library".
After a database script test in a certain database script file passes and a corresponding database has been created or updated based on the database script in the database file, the database script file needs to be stored in a script library. When a certain database script file needs to be stored in the script library, a developer can trigger a file update instruction for updating the database script file in the script library. The file updating instruction carries a unique identifier of the target database script file to be updated in the script library. If the server detects that the user triggers a file updating instruction for updating the database script file in the script library, the server extracts the unique identification of the target database script file to be updated into the script library from the file updating instruction.
Specifically, if the server detects that a new file is added to the script library by a user or detects that the content of a certain database script file in the script library is updated by the user, the server identifies that a file updating instruction for updating the database script file in the script library is detected. Wherein the server detects that the user adds a new file to the script library includes, but is not limited to, the following: detecting a file pasting instruction triggered by a user in a script library; or detecting that the user triggers an operation of dragging the file into the script library.
The server extracts the unique identification of the target database script file to be updated into the script library from the file update instruction, including but not limited to the following:
if the server detects that the user triggers the file pasting instruction in the script library, determining the name of the file aimed at by the file pasting instruction as the unique identification of the script file of the target database to be updated in the script library.
If the server detects that the user triggers file dragging operation of dragging the file into the script library, determining the name of the file aimed at by the file dragging operation as the unique identification of the script file of the target database to be updated into the script library.
If the server detects that the user performs the updating operation on the content of a certain database script file in the script library, determining the unique identifier of the database script file aimed at by the updating operation as the unique identifier of the target database script file.
S12: and acquiring a database script in the target database script file.
In this embodiment, after receiving a file update instruction for updating a database script file in a script library, a server obtains a database script from a target database script file to be updated to the script library.
Specifically, the server obtaining the database script in the target database script file may include, but is not limited to, the following cases:
if the server detects that the user triggers the file pasting instruction in the script library, determining the file to be pasted aimed at by the file pasting instruction as a target database script file, acquiring the content of the file to be pasted, and determining the acquired content of the file to be pasted as a database script in the target database script file.
If the server detects that the user triggers the file dragging operation of dragging the file into the script library, determining the file aimed at by the file dragging operation (namely the dragged file) as a target database script file, acquiring the content of the dragged file, and determining the acquired content of the dragged file as a database script in the target database script file.
If the server detects that the user performs the updating operation on the content of a certain database script file in the script library, determining the database script file aimed at by the updating operation as a target database script file, acquiring the updated content of the database script file aimed at by the updating operation, and determining the updated content of the database script file aimed at by the acquired updating operation as the database script in the target database script file.
S13: and determining a first target database matched with the target database script file from deployed databases based on the unique identification of the target database script file.
In the embodiment of the invention, after obtaining the unique identifier of the target database script file to be updated into the script library from the file updating instruction, the server determines a first target database matched with the target database script file from deployed databases based on the unique identifier of the target database script file.
In practice, the same database is typically deployed in a plurality of different database environments. Wherein, different database environments can be distinguished by a server carrying the database environments. Servers used to host different database environments have different internet protocol (Internet Protocol, IP) addresses. Each database that has been deployed has a unique identification, the unique identification of the different databases being different. The unique identification of the database may be the name of the database. It should be noted that, there is an association relationship between the unique identifier of the database and the unique identifier of the database script file in which the database script for creating the database is located. For example, in practical applications, the unique identifier of the database may be the same as the unique identifier of the database script file in which the database script is used to create the database, or the unique identifier of the database may include the same character string as the unique identifier of the database script file in which the database script is used to create the database.
The server may determine a first target database matching the target database script file from all of the databases deployed based on the unique identification of the target database script file and the unique identification of each database deployed in each database environment. Specifically, the server may compare the unique identifier of the target database script file with the unique identifiers of the databases deployed in the database environments, respectively, and if the unique identifier of a database is identical to the unique identifier of the target database script file, or the unique identifier of a database contains the same character string as the unique identifier of the target database script file, determine the database as a first target database that matches the target database script file.
S14: and generating a first database script file corresponding to the first target database based on the database object contained in the first target database and a preset database script generation strategy.
In the embodiment of the invention, after determining the first target database matched with the target database script file, the server acquires the database object of the first target database, and generates the first database script file corresponding to the first target database based on the database object contained in the first target database and a preset database script generation strategy. The database script generation strategy is used for reversely converting the database into corresponding database scripts based on the database objects contained in the database.
In practical application, the preset database script generation strategy may be determined according to the database type of the first target database. For example, if the first target database is an SQL Server database, the preset database script generation policy may be constituted by a transfer class provided by the SQL Server database.
After generating a first database script file corresponding to the first target database, the server acquires a database script in the first database script file. And comparing the database scripts in the first database script file with the database scripts in the target database script file. And if the database script in the target database script file is identical to the database script in the first database script file, executing S15.
S15: and if the database script in the target database script file is completely the same as the database script in the first database script file, storing the target database script file into the script library.
In the embodiment of the invention, if the server detects that the database script in the target database script file is identical to the database script in the first database script file, the server indicates that the target database script file to be updated into the script library is the latest version of the database script file corresponding to the deployed first target database, and at the moment, the server stores the target database script file into the script library.
The server stores the target database script file into the script library including, but not limited to, the following:
if the file updating instruction is triggered by triggering the file pasting instruction in the script library by the user, the server pastes the file to be pasted, which is aimed at by the file pasting instruction, into the script library.
If the file update instruction is triggered by the user by triggering a file dragging operation of dragging the file into the script library, the server controls the script library to receive the file dragged into the script library.
If the file updating instruction is triggered by the user by updating the content of a certain database script file in the script library, the server stores the updated content in the database script file aimed at by the updating operation.
It can be seen from the foregoing that, in the method for updating a database script file provided in this embodiment, when a file update instruction for updating a database script file in a script library is received, a first target database matching a target database script file to be updated into the script library is determined from each deployed database, the first target database is converted into a first database script file corresponding to the first target database based on a preset database script generating policy, data analysis is performed on a database script in the database script file, and when the database script in the target database script file is identical to the database script in the first database script file, it is illustrated that the target database script file corresponds to the deployed first target database, and at this time, the target database script file is stored into the script library, thereby ensuring that the target database script file finally stored in the script library corresponds to the deployed corresponding database.
Referring to fig. 2, fig. 2 is a flowchart illustrating an implementation method of updating a database script file according to a second embodiment of the present invention. Compared to the corresponding embodiment of fig. 1, the updating method of the database script file provided in this embodiment further includes S16 after S14, and is described in detail as follows:
s16: and if the database script in the target database script file is completely the same as the database script in the first database script file, storing the target database script file into the script library.
In this embodiment, if the server detects that the database script in the target database script file is not identical to the database script in the first database script file, it indicates that the target database script file to be updated in the script database is not the latest version of the database script file corresponding to the first target database, and at this time, in order to avoid that the target database script file to be updated in the script database covers the latest version of the database script file corresponding to the first target database, thereby causing the database script file corresponding to the first target database to be finally stored in the script database to be not the latest version of the database script file corresponding to the first target database, the server does not respond to the file update instruction for updating the database script file in the script database. I.e., the server will not store the target database script file into the script library.
As can be seen from the foregoing, in the method for updating a database script file provided in this embodiment, when it is detected that the database script in the target database script file is not identical to the database script in the first database script file, a file update instruction for updating the database script file in the script library is not responded, so that it is avoided that the latest version of the database script file corresponding to the first target database stored in the script library is covered by the target database script file to be updated in the script library, and it is ensured that the finally stored database script file corresponding to the first target database in the script library is the latest version of the database script file corresponding to the first target database.
Referring to fig. 3, fig. 3 is a flowchart showing a specific implementation of S16 in a method for updating a database script file according to a third embodiment of the present invention.
As an embodiment of the present invention, when the database script in the target database script file is not exactly the same as the database script in the first database script file, there is also the following case: the target database script file is the latest version of the database script file corresponding to the first target database, but an error occurs in the process of creating the database based on the database script in the target database script file, or an error occurs in the process of generating the first database script file based on a preset database script generation policy, so that the finally generated database script in the first database script file is different from the finally generated database script in the target database script file. In order to determine whether the above situation occurs, the server may respectively obtain databases matching the target database script files from different database environments, and compare the database script files corresponding to the databases matching the target database script files obtained from the different database environments, so as to further determine whether the target database script file is the latest version of the database script file corresponding to the first target database.
Therefore, in this embodiment, S13 may specifically include the following steps:
a first target database that matches the target database script file is determined from among the respective databases deployed in the first database environment based on the unique identification of the target database script file.
In this embodiment, after obtaining the unique identifier of the target database script file to be updated to the script library from the file update instruction, the server determines, from each database deployed in the first database environment, a first target database that matches the target database script file based on the unique identifier of the target database script file. The first database environment is any one of a plurality of database environments which are built in advance and used for deploying databases, and a database matched with the target database script file is deployed in the first database environment.
Specifically, the server may detect whether a database matched with the target database script file is deployed in each pre-built database environment based on the unique identifier of the target database script file, and if it is detected that a database matched with the target database script file is deployed in at least two database environments, randomly select one database environment from the at least two database environments as a first database environment, and acquire a first target database matched with the target database script file from the first database environment.
In this embodiment, S16 may be implemented by S161 to S163 shown in fig. 3, and is described in detail as follows:
s161: and if the database script in the target database script file is not identical to the database script in the first database script file, determining a second target database matched with the target database script file from all databases deployed in a second database environment.
In this embodiment, if the server detects that the database script in the target database script file is not identical to the database script in the first database script file, the server determines a second target database matching the target database script file from the databases deployed in the second database environment.
The second database environment is any one of a plurality of database environments which are built in advance and used for deploying databases, a database matched with the target database script file is deployed in the second database environment, and the second database environment is different from the first database environment.
Specifically, if the server detects that databases matched with the target database script files are deployed in at least two database environments, removing the selected first database environment from the at least two database environments, randomly selecting one database environment from the rest database environments after the first database environment is removed as a second database environment, and acquiring a second target database matched with the target database script files from the second database environment.
S162: and generating a second database script file corresponding to the second target database based on the database object contained in the second target database and a preset database script generation strategy.
In this embodiment, after the server obtains the second target database matching with the target database script file from the second database environment, the server generates a second database script file corresponding to the second target database based on the database object included in the second target database and the preset database script generating policy. The database script generation strategy is used for reversely converting the database into corresponding database scripts based on the database objects contained in the database. In practical application, the preset database script generation strategy may be determined according to the database type of the second target database. For example, if the second target database is an SQL Server database, the preset database script generation policy may be constituted by a transfer class provided by the SQL Server database.
And after the server generates a second database script file corresponding to the second target database, acquiring a database script in the second database script file. And comparing the database scripts in the second database script file with the database scripts in the first database script file. If the database script in the second database script file is identical to the database script in the first database script file, S163 is executed.
S163: and if the database script in the second database script file is completely the same as the database script in the first database script file, not responding to the file updating instruction.
In this embodiment, if the server detects that the database script in the second database script file is identical to the database script in the first database script file, it further determines that the target database script file to be updated to the script library is not the latest version of the database script file corresponding to the first target database, and at this time, the server does not respond to a file update instruction for updating the database script file in the script library. I.e., the server will not store the target database script file into the script library.
As can be seen from the foregoing, in the method for updating a database script file provided in this embodiment, when it is detected that a database script in a target database script file is not completely identical to a database script in a first database script file deployed in a first database environment, in order to further determine whether the target database script file is a latest version of the database script file corresponding to the first target database, a server obtains a second target database matching the target database script file from a second database environment, generates a second database script file corresponding to the second target database, and if the database script in the second database script file is completely identical to the database script in the first database script file, determines that the target database script file is not the latest version of the database script file corresponding to the first target database, at this time, the server does not respond to a file update instruction, thereby further ensuring that the target database script file finally stored in the script file corresponds to the corresponding database script file deployed in the first target database environment, and improving the accuracy of updating the database script file in the script file.
Referring to fig. 4, fig. 4 is a flowchart illustrating an implementation method of updating a database script file according to a fourth embodiment of the present invention. Compared with the corresponding embodiment of fig. 3, the updating method of the database script file provided in this embodiment further includes S164 to S165 after S162, and is described in detail as follows:
s164: and if the database script in the second database script file is not identical to the database script in the first database script file, comparing the database script in the second database script file with the database foot in the target database script file.
In this embodiment, when the database script in the target database script file is not identical to the database script in the first database script file, and the database script in the second database script file is not identical to the database script in the first database script file, the server compares the database script in the second database script file with the database script in the target database script file. Specifically, if the server detects that the database script in the second database script file is identical to the database script in the target database script file, S165 is executed.
S165: and if the database script in the second database script file is completely the same as the database script in the target database script file, storing the target database script file into the script library.
In this embodiment, if the server detects that the database script in the second database script file is identical to the database script in the target database script file, it indicates that an error occurs in the process of creating the first target database matched with the target database script file, or an error occurs in the process of converting the first target database into the first database script file, where the target database script file is the latest version of the database script file corresponding to the corresponding database, and at this time, the server stores the target database script file into the script library.
As can be seen from the foregoing, in the method for updating a database script file provided in this embodiment, when it is detected that the database script in the second database script file corresponding to the second target database is not completely identical to the database script in the first database script file corresponding to the first target database, the database script in the second database script file is further compared with the database script in the target database script file, and if the database script in the second database script file is completely identical to the database script in the target database script file, it is indicated that the target database script file is the latest version of the database script file corresponding to the corresponding database, and at this time, the server stores the target database script file into the script library, thereby ensuring that the target database script file finally stored in the script library corresponds to the deployed corresponding database.
Referring to fig. 5, fig. 5 is a flowchart illustrating an implementation method of updating a database script file according to a fifth embodiment of the present invention. Compared to the corresponding embodiments of fig. 1 to 4, in the method for updating a database script file provided in this embodiment, the step of storing the target database script file in the script library may be implemented through S51 to S52, and is described in detail as follows:
s51: if the script library contains a database script file with the unique identifier identical to the unique identifier of the target database script file, replacing the database script file with the unique identifier identical to the unique identifier of the target database script file by the target database script file.
S52: and if the script library does not contain the database script file with the unique identifier identical to the unique identifier of the target database script file, storing the target database script file into the script library.
Because the unique identifiers of the database script files of different versions corresponding to the same database are the same, and only the latest version of the database script file corresponding to the database is stored in the script library, in this embodiment, when the server stores the target database script file in the script library, it is detected whether the script library contains the database script file with the unique identifier identical to the unique identifier of the target database script file.
If the server detects that the script library contains the database script file with the unique identifier identical to the unique identifier of the target database script file, the server replaces the database script file with the unique identifier identical to the unique identifier of the target database script file, wherein the unique identifier is contained in the script library.
If the server detects that the script library does not contain the database script file with the same unique identification as the target database script file, the server directly stores the target database script file in the script library.
It can be seen that, in the method for updating a database script file provided in this embodiment, when it is detected that the script library includes a database script file whose unique identifier is the same as that of the target database script file, the database script file whose unique identifier is the same as that of the target database script file included in the script library is replaced with the target database script file, so that the storage space of the script library is saved.
Fig. 6 is a block diagram of a server according to an embodiment of the present invention, where the server includes units for performing steps in the embodiments corresponding to fig. 1 to 5. Please refer to fig. 1 to 5 and the related descriptions in the embodiments corresponding to fig. 1 to 5. For convenience of explanation, only the portions related to the present embodiment are shown. Referring to fig. 6, the server 600 includes: an instruction receiving unit 61, a first acquiring unit 62, a first determining unit 63, a first generating unit 64, and a synchronizing unit 65. Wherein:
The instruction receiving unit 61 is configured to receive a file update instruction for updating a database script file in a script library; and the file updating instruction carries a unique identifier of the target database script file to be updated in the script library.
The first obtaining unit 62 is configured to obtain a database script in the target database script file.
The first determining unit 63 is configured to determine, from the deployed databases, a first target database that matches the target database script file, based on the unique identifier of the target database script file.
The first generating unit 64 is configured to generate a first database script file corresponding to the first target database based on a database object included in the first target database and a preset database script generating policy.
The synchronization unit 65 is configured to store the target database script file into the script library if the database script in the target database script file is identical to the database script in the first database script file.
As an embodiment of the present invention, the server 600 further includes a first instruction processing unit.
And the first instruction processing unit is used for not responding to the file updating instruction if the database script in the target database script file is not identical to the database script in the first database script file.
As an embodiment of the present invention, the first determining unit 63 is specifically configured to determine, from the respective databases deployed in the first database environment, a first target database matching the target database script file based on the unique identifier of the target database script file.
The first instruction processing unit specifically includes a second determining unit, a second generating unit, and a second instruction processing unit. Wherein:
and the second determining unit is used for determining a second target database matched with the target database script file from all databases deployed in a second database environment if the database script in the target database script file is not identical to the database script in the first database script file.
The second generating unit is used for generating a second database script file corresponding to the second target database based on the database object contained in the second target database and a preset database script generating strategy.
And the second instruction processing unit is used for not responding to the file updating instruction if the database script in the second database script file is completely the same as the database script in the first database script file.
As an embodiment of the present invention, the server 600 further includes a comparison unit.
And the comparison unit is used for comparing the database script in the second database script file with the database foot in the target database script file if the database script in the second database script file is not identical to the database script in the first database script file.
The synchronization unit 65 is further configured to store the target database script file into the script library if the database script in the second database script file is identical to the database script in the target database script file.
As an embodiment of the present invention, the synchronization unit 65 specifically includes a replacement unit and a storage unit. Wherein:
and the replacing unit is used for replacing the database script file with the unique identifier identical to the unique identifier of the target database script file by the target database script file if the database script file with the unique identifier identical to the unique identifier of the target database script file is contained in the script library.
And the storage unit is used for storing the target database script file into the script library if the script library does not contain the database script file with the unique identifier identical to the unique identifier of the target database script file.
As can be seen from the foregoing, when a server provided in this embodiment receives a file update instruction for updating a database script file in a script library, a first target database matching a target database script file to be updated into the script library is determined from each deployed database, the first target database is converted into a first database script file corresponding to the first target database based on a preset database script generation policy, data analysis is performed on the database script in the database script file, and when the database script in the target database script file is identical to the database script in the first database script file, it is indicated that the target database script file corresponds to the deployed first target database, and at this time, the target database script file is stored into the script library, thereby ensuring that the target database script file finally stored in the script library corresponds to the deployed corresponding database.
Fig. 7 is a block diagram of a server according to another embodiment of the present invention. As shown in fig. 7, the server 7 of this embodiment includes: a processor 70, a memory 71 and a computer program 72 stored in said memory 71 and executable on said processor 70, for example a program for a method of updating a database script file. The steps of the embodiments of the method for updating the database script files described above, such as S11 to S15 shown in fig. 1, are implemented when the processor 70 executes the computer program 72. Alternatively, the processor 70 may implement the functions of each unit in the embodiment corresponding to fig. 6, for example, the functions of the units 61 to 65 shown in fig. 6, when executing the computer program 72, and the detailed description of the embodiment corresponding to fig. 6 will be referred to herein, which is omitted.
By way of example, the computer program 72 may be divided into one or more units, which are stored in the memory 71 and executed by the processor 70 to accomplish the present invention. The one or more units may be a series of computer program instruction segments capable of performing a specific function for describing the execution of the computer program 72 in the server 7. For example, the computer program 72 may be divided into an instruction receiving unit, a first acquiring unit, a first determining unit, a first generating unit and a synchronizing unit, each unit functioning specifically as described above.
The server may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of the server 7 and is not limiting of the server 7, and may include more or fewer components than shown, or may combine some components, or different components, e.g., the server may also include input and output devices, network access devices, buses, etc.
The processor 70 may be a central processing unit (Central Processing Unit, CPU), or may be another general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may be an internal storage unit of the server 7, such as a hard disk or a memory of the server 7. The memory 71 may be an external storage device of the server 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the server 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the server 7. The memory 71 is used for storing the computer program as well as other programs and data required by the server. The memory 71 may also be used for temporarily storing data that has been output or is to be output.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.

Claims (4)

1. A method for updating a database script file, comprising:
receiving a file updating instruction for updating a database script file in a script library; the script library is used for storing database script files, and the file updating instruction carries a unique identifier of a target database script file to be updated in the script library;
acquiring a database script in the target database script file;
determining a first target database matching the target database script file from among the respective databases deployed in the first database environment based on the unique identification of the target database script file;
generating a first database script file corresponding to the first target database based on a database object contained in the first target database and a preset database script generation strategy;
if the database script in the target database script file is identical to the database script in the first database script file, storing the target database script file into the script library;
if the database script in the target database script file is not identical to the database script in the first database script file, determining a second target database matched with the target database script file from all databases deployed in a second database environment;
Generating a second database script file corresponding to the second target database based on a database object contained in the second target database and a preset database script generation strategy;
if the database script in the second database script file is identical to the database script in the first database script file, not responding to the file updating instruction;
the generating a second database script file corresponding to the second target database based on the database object contained in the second target database and a preset database script generating policy further includes:
if the database script in the second database script file is not identical to the database script in the first database script file, comparing the database script in the second database script file with the database foot in the target database script file;
and if the database script in the second database script file is completely the same as the database script in the target database script file, storing the target database script file into the script library.
2. The method for updating a database script file according to claim 1, wherein storing the target database script file in the script library comprises:
If the script library contains a database script file with the unique identifier identical to the unique identifier of the target database script file, replacing the database script file with the unique identifier identical to the unique identifier of the target database script file by the target database script file;
and if the script library does not contain the database script file with the unique identifier identical to the unique identifier of the target database script file, storing the target database script file into the script library.
3. A server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the steps of when executing the computer program:
receiving a file updating instruction for updating a database script file in a script library; the script library is used for storing database script files, and the file updating instruction carries a unique identifier of a target database script file to be updated in the script library;
acquiring a database script in the target database script file;
determining a first target database matching the target database script file from among the respective databases deployed in the first database environment based on the unique identification of the target database script file;
Generating a first database script file corresponding to the first target database based on a database object contained in the first target database and a preset database script generation strategy;
if the database script in the target database script file is identical to the database script in the first database script file, storing the target database script file into the script library;
if the database script in the target database script file is not identical to the database script in the first database script file, determining a second target database matched with the target database script file from all databases deployed in a second database environment;
generating a second database script file corresponding to the second target database based on a database object contained in the second target database and a preset database script generation strategy;
if the database script in the second database script file is identical to the database script in the first database script file, not responding to the file updating instruction;
the generating a second database script file corresponding to the second target database based on the database object contained in the second target database and a preset database script generating policy further includes:
If the database script in the second database script file is not identical to the database script in the first database script file, comparing the database script in the second database script file with the database foot in the target database script file;
and if the database script in the second database script file is completely the same as the database script in the target database script file, storing the target database script file into the script library.
4. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method according to any one of claims 1 to 2.
CN201810915165.XA 2018-08-13 2018-08-13 Database script file updating method, server and medium Active CN109213748B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810915165.XA CN109213748B (en) 2018-08-13 2018-08-13 Database script file updating method, server and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810915165.XA CN109213748B (en) 2018-08-13 2018-08-13 Database script file updating method, server and medium

Publications (2)

Publication Number Publication Date
CN109213748A CN109213748A (en) 2019-01-15
CN109213748B true CN109213748B (en) 2023-10-27

Family

ID=64987807

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810915165.XA Active CN109213748B (en) 2018-08-13 2018-08-13 Database script file updating method, server and medium

Country Status (1)

Country Link
CN (1) CN109213748B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112632159B (en) * 2020-12-01 2021-09-28 腾讯科技(深圳)有限公司 Database access control method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004030689A (en) * 1998-11-20 2004-01-29 Fujitsu Ltd Device and method of operation management using guidance script, and operation management program recording medium
CN104572644A (en) * 2013-10-10 2015-04-29 北京大学 Database updating device and database updating method
CN106708740A (en) * 2017-01-10 2017-05-24 网易(杭州)网络有限公司 Script testing method and device
CN107844485A (en) * 2016-09-18 2018-03-27 平安科技(深圳)有限公司 The update method and device of test script file

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9836297B2 (en) * 2015-08-21 2017-12-05 Tata Consultancy Services Limited Computer implemented method and system for automatically deploying and versioning scripts in a computing environment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004030689A (en) * 1998-11-20 2004-01-29 Fujitsu Ltd Device and method of operation management using guidance script, and operation management program recording medium
CN104572644A (en) * 2013-10-10 2015-04-29 北京大学 Database updating device and database updating method
CN107844485A (en) * 2016-09-18 2018-03-27 平安科技(深圳)有限公司 The update method and device of test script file
CN106708740A (en) * 2017-01-10 2017-05-24 网易(杭州)网络有限公司 Script testing method and device

Also Published As

Publication number Publication date
CN109213748A (en) 2019-01-15

Similar Documents

Publication Publication Date Title
US10621211B2 (en) Language tag management on international data storage
US9471285B1 (en) Identifying software components in a software codebase
US8245217B2 (en) Management of software and operating system updates required for the process of creating a virtual machine facsimile of an existing physical or virtual machine
US20140208314A1 (en) Automatically Propagating Updates in a Data Center
US9298448B2 (en) System and method for run time dependency resolution
US20170147469A1 (en) Correlation of source code with system dump information
US20160098390A1 (en) Command history analysis apparatus and command history analysis method
US9898386B2 (en) Detecting byte ordering type errors in software code
US20130339787A1 (en) Systematic failure remediation
JP2018519556A (en) System and method for provisioning cloud services across heterogeneous computing environments
US20160266924A1 (en) Apparatus and method for identifying a virtual machine having changeable settings
US8799716B2 (en) Heap dump occurrence detection
US20160098563A1 (en) Signatures for software components
KR20230130089A (en) System and method for selection and discovery of vulnerable software packages
US20140359077A1 (en) Method and apparatus for transmitting symbol files
US20160147547A1 (en) Metadata-based class loading using a content repository
CN113515303B (en) Project transformation method, device and equipment
CN109213748B (en) Database script file updating method, server and medium
CN110244954B (en) Compiling method and equipment for application program
US10599424B2 (en) Committed program-code management
CN112800194A (en) Interface change identification method, device, equipment and storage medium
US20220374528A1 (en) Evaluation apparatus, evaluation system, evaluation method, and program
US9465687B2 (en) Information processing apparatus and information processing method
US20150331772A1 (en) Methods for updating diagnostic tools on a hardware device and devices thereof
US20150347402A1 (en) System and method for enabling a client system to generate file system operations on a file system data set using a virtual namespace

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant