CN112711573A - Database structure difference report generation method and device - Google Patents

Database structure difference report generation method and device Download PDF

Info

Publication number
CN112711573A
CN112711573A CN202110052567.3A CN202110052567A CN112711573A CN 112711573 A CN112711573 A CN 112711573A CN 202110052567 A CN202110052567 A CN 202110052567A CN 112711573 A CN112711573 A CN 112711573A
Authority
CN
China
Prior art keywords
database
file
database structure
generating
difference report
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.)
Pending
Application number
CN202110052567.3A
Other languages
Chinese (zh)
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.)
Sinochem Petrochemical Sales Co Ltd
Original Assignee
Sinochem Petrochemical Sales Co 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 Sinochem Petrochemical Sales Co Ltd filed Critical Sinochem Petrochemical Sales Co Ltd
Priority to CN202110052567.3A priority Critical patent/CN112711573A/en
Publication of CN112711573A publication Critical patent/CN112711573A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases

Abstract

The invention provides a database structure difference report generation method and a device, wherein the method comprises the following steps: determining the connectivity of the first database and the second database; and generating a database structure difference report of the first database and the second database according to the communication of the first database and the second database and a preset comparison strategy. The scheme of the invention solves the problem that two environment databases cannot be connected at the same time, is convenient for project group investigation, and is designed and filed at the same time.

Description

Database structure difference report generation method and device
Technical Field
The present invention relates to the field of database processing technologies, and in particular, to a method and an apparatus for generating a database structure difference report.
Background
Database difference comparison tools are currently generally completed based on a database client, that is, graphical operation tools (such as Navicat) that are generally windowed have many disadvantages:
the graphical operation needs more steps of operation, generally, a database is manually selected and a table is selected, the whole database cannot be directly compared, and the table cannot be configured by filling an expression matching mode;
the operation process is troublesome, graphical operation is required each time, and the report can not be obtained by clicking one executable file.
The most critical problem is that different databases and different environments are isolated from each other by network, which results in inefficient comparison, and also creates security problems if different database environments (especially production environments) are simultaneously accessed.
Disclosure of Invention
The technical problem to be solved by the invention is to provide a database structure difference report generation method and device, which solve the problem that two environment databases cannot be connected simultaneously in a real service scene, facilitate project group investigation, and simultaneously design and file.
In order to solve the technical problems, the technical scheme of the invention is as follows:
a database structure difference report generation method comprises the following steps:
determining the connectivity of the first database and the second database;
and generating a database structure difference report of the first database and the second database according to the communication of the first database and the second database and a preset comparison strategy.
Optionally, determining connectivity between the first database and the second database includes:
acquiring first connection information configured for a first database and second connection information configured for a second database;
and testing the connectivity of the first database according to the first connection information and testing the connectivity of the second database according to the second connection information.
Optionally, generating a database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy, where the database structure difference report includes:
if the first database is communicated and the second database is not communicated, generating a first database structure file of the first database;
and comparing the first database structure file with a second database structure file of a second database generated in advance to generate a database structure difference report of the first database and the second database.
Optionally, generating a database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy, where the database structure difference report includes:
if the first database is communicated and the second database is communicated, generating a first database structure file of the first database and generating a second database structure file of the second database;
and comparing the first database structure file with the second database structure file to generate a database structure difference report of the first database and the second database.
Optionally, generating a database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy, where the database structure difference report includes:
if the first database is not communicated and the second database is not communicated, acquiring a first database structure file of the pre-generated first database and a second database structure file of the pre-generated second database;
and comparing the first database structure file with the second database structure file to generate a database structure difference report of the first database and the second database.
Optionally, the database structure difference report generating method further includes:
and if the first database is converted from the non-communication state to the communication state, generating a new first database structure file of the first database, and covering the original first database structure file with the new first database structure file.
Optionally, the database structure difference report includes at least one of:
the method comprises the steps of obtaining a database table, names of objects in the database table, information of whether the corresponding objects exist in a first database, information of whether the corresponding objects exist in a second database and field difference information corresponding to the objects.
Optionally, the first database is at least one of the following: dev, test, uat, prod;
the second database is at least one of: dev, test, uat, prod.
Optionally, the first database structure file is a file of a schema file structure;
the first database structure file is a file of a schema file structure.
An embodiment of the present invention further provides a database structure difference report generation apparatus, including:
the determining module is used for determining the connectivity of the first database and the second database;
and the generating module is used for generating database structure difference reports of the first database and the second database according to the communication of the first database and the second database and a preset comparison strategy.
The scheme of the invention at least comprises the following beneficial effects:
according to the scheme, the communication performance of the first database and the second database is determined; and generating a database structure difference report of the first database and the second database according to the communication of the first database and the second database and a preset comparison strategy. The problem that two environment databases cannot be connected simultaneously in a real service scene is solved, the problem of project group investigation is facilitated, and design and filing are carried out simultaneously.
Drawings
FIG. 1 is a schematic flow chart of a database structure difference report generation method of the present invention;
FIG. 2 is a schematic view of a processing flow of a database structure difference report generation method according to the present invention in a case where two database environments are UAT and PROD, respectively;
fig. 3 is a schematic block diagram of a database structure difference report generation apparatus according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
As shown in fig. 1, an embodiment of the present invention provides a database structure difference report generation method, including:
step 11, determining the connectivity of the first database and the second database;
and 12, generating database structure difference reports of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison strategy.
According to the embodiment, the corresponding database structure difference report can be generated according to the communication performance of the database and the preset comparison strategy, the difference comparison is further carried out by utilizing the structure file, the problem that two environment databases cannot be connected simultaneously in a real business scene is solved, the problem of project group investigation is facilitated, and the design and filing are carried out simultaneously.
In an alternative embodiment of the present invention, step 11 may include:
acquiring first connection information configured for a first database and second connection information configured for a second database; and testing the connectivity of the first database according to the first connection information and testing the connectivity of the second database according to the second connection information.
Here, the first database is at least one of: dev, test, uat, prod; the second database is at least one of: dev, test, uat, prod.
In an optional embodiment of the present invention, for the database structure difference report in step 12, optionally, the database structure difference report includes at least one of the following:
the method comprises the steps of obtaining a database table, names of objects in the database table, information of whether the corresponding objects exist in a first database, information of whether the corresponding objects exist in a second database and field difference information corresponding to the objects.
In an alternative embodiment of the present invention, the database structure difference report is shown in table 1:
Figure BDA0002899599310000041
Figure BDA0002899599310000051
TABLE 1
Here, the types of the first database structure file and the second database structure file are, optionally, the first database structure file is a file of a schema file structure; the first database structure file is a file of a schema file structure.
In an alternative embodiment of the present invention, as shown in fig. 2, the two database environments are UAT (user acceptance test) and PROD (production), respectively, and the database structure difference report generation is performed by the following processes:
configuring the connection information of 2 databases, and setting the comparison mode to be an off-line mode or an on-line mode, wherein the off-line mode means that all the databases generate schema files;
performing the comparison, there may be cases including:
the first condition is as follows: if the first database is communicated and the second database is not communicated, generating a first database structure file of the first database; comparing the first database structure file with a second database structure file of a second database generated in advance to generate a database structure difference report of the first database and the second database;
here, in an alternative embodiment of the present invention,
assume that the database environment of the first database is UAT and the database environment of the second database is PROD. The method comprises the steps that databases in the UAT environment are communicated, the databases in the PROD environment are not communicated, database structure files in the UAT environment are generated, the database structure files in the UAT environment are compared with pre-generated database structure files in the PROD environment of the databases in the PROD environment, and database structure difference reports of the databases in the UAT environment and the PROD environment are generated;
assume that the database environment of the first database is PROD and the database environment of the second database is UAT. And the database under the PROD environment is communicated, the database under the UAT environment is not communicated, a database structure file under the PROD environment is generated, the database structure file under the PROD environment is compared with a pre-generated database structure file under the UAT environment of the database under the UAT environment, and a database structure difference report of the database under the PROD environment and the database under the UAT environment is generated.
Case two: comparing the strategies to generate a database structure difference report of the first database and the second database, wherein the database structure difference report comprises: if the first database is communicated and the second database is communicated, generating a first database structure file of the first database and generating a second database structure file of the second database; comparing the first database structure file with the second database structure file to generate a database structure difference report of the first database and the second database;
here, in an alternative embodiment of the present invention, the database environment of the first database is set to be UAT, and the database environment of the second database is set to be PROD. The method comprises the following steps that databases in a UAT environment are communicated, and databases in a PROD environment are communicated, so that database structure files in the UAT environment of the databases in the UAT environment and database structure files in the PROD environment of the databases in the PROD environment are generated; comparing the database structure file under the UAT environment with the database structure file under the PROD environment to generate a database structure difference report of the database under the UAT environment and the database under the PROD environment;
in the case where the database environment of the first database is PROD and the database environment of the second database is UAT, the procedure is the same as described above.
Case three: if the first database is not communicated and the second database is not communicated, acquiring a first database structure file of the pre-generated first database and a second database structure file of the pre-generated second database; comparing the first database structure file with the second database structure file to generate a database structure difference report of the first database and the second database;
here, in an alternative embodiment of the present invention, the database environment of the first database is set to be UAT, and the database environment of the second database is set to be PROD. The method comprises the steps that databases in UAT environment are not communicated, and databases in PROD environment are not communicated, and a pre-generated database structure file in UAT environment of the databases in UAT environment and a pre-generated database structure file in PROD environment of the databases in PROD environment are obtained; comparing the database structure file under the UAT environment with the database structure file under the PROD environment to generate a database structure difference report of the database under the UAT environment and the database under the PROD environment;
in the case where the database environment of the first database is PROD and the database environment of the second database is UAT, the procedure is the same as described above.
In an optional embodiment of the present invention, the database structure difference report generating method may further include:
and if the first database is converted from the non-communication state to the communication state, generating a new first database structure file of the first database, and covering the original first database structure file with the new first database structure file.
The above embodiments of the present invention support both online and offline modes of the database, with the core of support for the offline mode, which is not available with current tools of this type. And the embodiment of the invention can automatically detect the communication state of the database, regenerate the structure file and cover the local file once the database can be connected, keep the structure file to be the latest, and preferentially detect whether the structure file exists locally or not when the database is detected to be disconnected, and compare the structure file with the structure file. Therefore, the database structure comparison under the scene that the two databases are connected simultaneously can be realized.
As shown in fig. 3, an embodiment of the present invention further provides a database structure difference report generating apparatus 30, which is applied to a network device, where the apparatus 30 includes:
a determining module 31, configured to determine connectivity between the first database and the second database;
a generating module 32, configured to generate a database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy.
Optionally, determining connectivity between the first database and the second database includes:
acquiring first connection information configured for a first database and second connection information configured for a second database;
and testing the connectivity of the first database according to the first connection information and testing the connectivity of the second database according to the second connection information.
Optionally, generating a database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy, where the database structure difference report includes:
if the first database is communicated and the second database is not communicated, generating a first database structure file of the first database;
and comparing the first database structure file with a second database structure file of a second database generated in advance to generate a database structure difference report of the first database and the second database.
Optionally, generating a database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy, where the database structure difference report includes:
if the first database is communicated and the second database is communicated, generating a first database structure file of the first database and generating a second database structure file of the second database;
and comparing the first database structure file with the second database structure file to generate a database structure difference report of the first database and the second database.
Optionally, generating a database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy, where the database structure difference report includes:
if the first database is not communicated and the second database is not communicated, acquiring a first database structure file of the pre-generated first database and a second database structure file of the pre-generated second database;
and comparing the first database structure file with the second database structure file to generate a database structure difference report of the first database and the second database.
Optionally, generating a database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy, further comprising:
and if the first database is converted from the non-communication state to the communication state, generating a new first database structure file of the first database, and covering the original first database structure file with the new first database structure file.
Optionally, the database structure difference report includes at least one of: the method comprises the steps of obtaining a database table, names of objects in the database table, information of whether the corresponding objects exist in a first database, information of whether the corresponding objects exist in a second database and field difference information corresponding to the objects.
Optionally, the first database is at least one of the following: dev, test, uat, prod; the second database is at least one of: dev, test, uat, prod.
Optionally, the first database structure file is a file of a schema file structure; the first database structure file is a file of a schema file structure.
It should be noted that the apparatus is an apparatus corresponding to the above method embodiment, and all the implementations in the above embodiments are applicable to the embodiment of the apparatus, and the same technical effects can be achieved. The apparatus may further comprise a generating module 32 for processing information provided by the two databases of the determining module 31.
Embodiments of the present invention also provide a processor-readable storage medium having stored thereon processor-executable instructions for causing a processor to perform the method as described above. All the implementation manners in the above method embodiment are applicable to this embodiment, and the same technical effect can be achieved.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
Furthermore, it is to be noted that in the device and method of the invention, it is obvious that the individual components or steps can be decomposed and/or recombined. These decompositions and/or recombinations are to be regarded as equivalents of the present invention. Also, the steps of performing the series of processes described above may naturally be performed chronologically in the order described, but need not necessarily be performed chronologically, and some steps may be performed in parallel or independently of each other. It will be understood by those skilled in the art that all or any of the steps or elements of the method and apparatus of the present invention may be implemented in any computing device (including processors, storage media, etc.) or network of computing devices, in hardware, firmware, software, or any combination thereof, which can be implemented by those skilled in the art using their basic programming skills after reading the description of the present invention.
Thus, the objects of the invention may also be achieved by running a program or a set of programs on any computing device. The computing device may be a general purpose device as is well known. The object of the invention is thus also achieved solely by providing a program product comprising program code for implementing the method or the apparatus. That is, such a program product also constitutes the present invention, and a storage medium storing such a program product also constitutes the present invention. It is to be understood that the storage medium may be any known storage medium or any storage medium developed in the future. It is further noted that in the apparatus and method of the present invention, it is apparent that each component or step can be decomposed and/or recombined. These decompositions and/or recombinations are to be regarded as equivalents of the present invention. Also, the steps of executing the series of processes described above may naturally be executed chronologically in the order described, but need not necessarily be executed chronologically. Some steps may be performed in parallel or independently of each other.
While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (10)

1. A database structure difference report generation method is characterized by comprising the following steps:
determining the connectivity of the first database and the second database;
and generating a database structure difference report of the first database and the second database according to the communication of the first database and the second database and a preset comparison strategy.
2. The database structure discrepancy report generation method of claim 1 wherein determining the connectivity of the first database and the second database comprises:
acquiring first connection information configured for a first database and second connection information configured for a second database;
and testing the connectivity of the first database according to the first connection information and testing the connectivity of the second database according to the second connection information.
3. The database structure difference report generation method according to claim 1, wherein generating the database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy comprises:
if the first database is communicated and the second database is not communicated, generating a first database structure file of the first database;
and comparing the first database structure file with a second database structure file of a second database generated in advance to generate a database structure difference report of the first database and the second database.
4. The database structure difference report generation method according to claim 1, wherein generating the database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy comprises:
if the first database is communicated and the second database is communicated, generating a first database structure file of the first database and generating a second database structure file of the second database;
and comparing the first database structure file with the second database structure file to generate a database structure difference report of the first database and the second database.
5. The database structure difference report generation method according to claim 1, wherein generating the database structure difference report of the first database and the second database according to the connectivity of the first database and the second database and a preset comparison policy comprises:
if the first database is not communicated and the second database is not communicated, acquiring a first database structure file of the pre-generated first database and a second database structure file of the pre-generated second database;
and comparing the first database structure file with the second database structure file to generate a database structure difference report of the first database and the second database.
6. The database structure discrepancy report generation method according to claim 1, further comprising:
and if the first database is converted from the non-communication state to the communication state, generating a new first database structure file of the first database, and covering the original first database structure file with the new first database structure file.
7. The database structure discrepancy report generation method according to claim 1, wherein the database structure discrepancy report includes at least one of:
the method comprises the steps of obtaining a database table, names of objects in the database table, information of whether the corresponding objects exist in a first database, information of whether the corresponding objects exist in a second database and field difference information corresponding to the objects.
8. The database structure discrepancy report generation method of claim 1,
the first database is at least one of: dev, test, uat, prod;
the second database is at least one of: dev, test, uat, prod.
9. The database structure discrepancy report generation method of claim 3,
the first database structure file is a file of a schema file structure;
the first database structure file is a file of a schema file structure.
10. A database structure discrepancy report generating apparatus, comprising:
the determining module is used for determining the connectivity of the first database and the second database;
and the generating module is used for generating database structure difference reports of the first database and the second database according to the communication of the first database and the second database and a preset comparison strategy.
CN202110052567.3A 2021-01-15 2021-01-15 Database structure difference report generation method and device Pending CN112711573A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110052567.3A CN112711573A (en) 2021-01-15 2021-01-15 Database structure difference report generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110052567.3A CN112711573A (en) 2021-01-15 2021-01-15 Database structure difference report generation method and device

Publications (1)

Publication Number Publication Date
CN112711573A true CN112711573A (en) 2021-04-27

Family

ID=75549072

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110052567.3A Pending CN112711573A (en) 2021-01-15 2021-01-15 Database structure difference report generation method and device

Country Status (1)

Country Link
CN (1) CN112711573A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109918299A (en) * 2019-02-27 2019-06-21 洛阳中科汇成科技有限公司 A kind of method of comparison database architectural difference
CN110704475A (en) * 2019-09-29 2020-01-17 中国银行股份有限公司 Method and system for comparing ETL loading table structures
CN111190905A (en) * 2019-12-31 2020-05-22 北京奇才天下科技有限公司 Database table processing method and device and electronic equipment
CN112214500A (en) * 2019-07-09 2021-01-12 北京京东尚科信息技术有限公司 Data comparison method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109918299A (en) * 2019-02-27 2019-06-21 洛阳中科汇成科技有限公司 A kind of method of comparison database architectural difference
CN112214500A (en) * 2019-07-09 2021-01-12 北京京东尚科信息技术有限公司 Data comparison method and device, electronic equipment and storage medium
CN110704475A (en) * 2019-09-29 2020-01-17 中国银行股份有限公司 Method and system for comparing ETL loading table structures
CN111190905A (en) * 2019-12-31 2020-05-22 北京奇才天下科技有限公司 Database table processing method and device and electronic equipment

Similar Documents

Publication Publication Date Title
US11163731B1 (en) Autobuild log anomaly detection methods and systems
CN102831052B (en) Test exemple automation generating apparatus and method
CN107689887B (en) Temporary control change online management system of nuclear power plant control system
WO2014000269A1 (en) Rule-based automated test data generation
CN102236672A (en) Method and device for importing data
CN111767704B (en) Excel form template generation method and device
CN107959579A (en) The dispositions method and deployment system of multisystem
CN110716966A (en) Data visualization processing method and system, electronic device and storage medium
CN109358898B (en) Information processing method and device, electronic equipment and storage medium
US20170185505A1 (en) Systems and methods for implementing an automated parallel deployment solution
CN111881042A (en) Automatic test script generation method and device and electronic equipment
CN106557419B (en) Program testing method and device
CN112711573A (en) Database structure difference report generation method and device
US8498963B2 (en) Method and system for data synchronization
CN104516970B (en) A kind of method and apparatus for carrying out log analysis
US10216619B2 (en) System and method for test automation using a decentralized self-contained test environment platform
US11928627B2 (en) Workflow manager
CN104239475A (en) Method and device for analyzing time series data
JP2018147350A (en) Apparatus for analyzing actual use of information processing system, and method for analyzing actual use
CN112256978A (en) Data processing method, device and medium based on data model
CN112015463A (en) Configuration version management device and working method thereof
CN111309368A (en) Development information management method, system, equipment and readable storage medium based on B/S framework
CN108614871B (en) Data query and result generation method, device, equipment and storage medium
CN111767233B (en) Service testing method and device based on intelligent express cabinet
US10936571B1 (en) Undo based logical rewind in a multi-tenant system

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