Summary of the invention
The present invention provides a kind of method of comparison database architectural difference, existing to solve to propose in above-mentioned background technique
Technology exists currently, database contrast difference has following defect: development process is at least needed to develop, be tested, formal three data
Lab environment, but then need to take a significant amount of time to be compared to guarantee that database structure is unified, currently without unified, intuitive
Method goes the problem of simplifying these operations.
Technical problem solved by the invention is realized using following technical scheme: a kind of comparison database architectural difference
Method, comprising:
Selection needs the type of database compared, carries out link verifying and compares two database structure differences, by two
The comparison result of database can be shown in the page in table form.
Further, described two database structure differences of comparison include that the basic comparison database of comparison one and another basis are right
Than database table information, column information, index information, function information and associated database information, by two basic comparison databases
Comparison result deposits in classification information database.
Further, two database structure differences are compared to specifically include:
Reading database: a basic comparison database and another basic comparison database are obtained by reading database sentence
Corresponding table information, column information, index information, function information;
Replicate data library: creating comparison data table in classification information database, will be obtained by replicate data library sentence
The corresponding table information of one basic comparison database and another basic comparison database, column information, index information, function information
Corresponding two comparison data tables of information data deposit classification information database;
Comparison database: pass through corresponding two comparison datas of comparison database sentence comparison-of-pair sorting's information database
Table.
Further, whether the content of reading includes: the title of database, type, length, is sky, default value, annotation, master
Key, trigger and relevant parameter.
Further, the specific statement form of reading database sentence in reading database are as follows:
GET_INDEX_INFO=" SELECT UPPER (table_name) TABLE_NAME, upper (index_
Name), INDEX_NAME, GROUP_CONCAT (upper (column_name) ORDER BY SEQ_IN_INDEX) COLUMNS
FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema=?=GROUP BY TABLE_
NAME, INDEX_NAME ".
Further, it in replicate data library, if having new data insertion, first empties original in classification information database
Table data.
Further, in comparison database, wherein a sentence has the comparison index difference of the comparison database sentence
Body statement form are as follows:
GET_DIFF_INDEX1=" select a.TABLE_NAME, a.INDEX_NAME INDEX_NAME1, ' index
There is no ' INDEX_NAME2, a.COLUMNS from t_indexinfo_1a where a.TABLE_NAME in (select
b.TABLE_NAME from t_tabinfo_2b)AND CONCAT(a.TABLE_NAME,'&',a.INDEX_NAME)not
in(select CONCAT(c.TABLE_NAME,'&',c.INDEX_NAME)from t_indexinfo_2c)”。
Further, the reading database sentence, replicate data library sentence and comparison database sentence are structuring
Query language.
Further, described that comparison result can be shown to include returning to list collection in the page in table form, in page
Comparison result is rendered to table and shown by face, while providing different information exporting Excel table.
Further, the method for the comparison database architectural difference further include:
Selection needs the type of database compared in the page, inputs correct database connection account and tests each database
Connection, each database connection of test includes connecting JDBC by java database to be added according to the type of database that the page selects
Respective drive is carried, the account information of input is verified;
If verifying is correct, establishes database connection and carry out data manipulation;
If verifying is incorrect, error message is prompted in the page;
The verifyings such as user name, password are carried out to disparate databases to execute in a browser.
Advantageous effects:
This patent needs the type of database compared using selection, carries out link verifying and two database structures of comparison are poor
It is different, the comparison result of two databases can be shown in the page in table form, since the present invention encapsulates code operation,
The type of database for needing to compare need to be only selected in the page, inputted correct database connection account, also be may be selected to need
The type of database to be compared carries out link verifying, and comparison result can be shown in the page in table form, and classification is clear,
Intuitively, Excel table clearly, can also be exported, there are two functions to form first is that testing each database for technical spirit tool of the invention
It connects, second is that two database structure differences of comparison, poor it is an object of the invention to simplify database structure by a kind of method
On the one hand different contrast operation has saved resource spending in this way, on the other hand can shorten developer and test basis
Information time, realization of the invention are conducive to save development cost, simplify convention control's difference complex operations, and result information
It is intuitive and easy to understand.
Embodiment:
The present embodiment: as shown in Figure 1, 2, a kind of method of comparison database architectural difference, comprising: what selection needed to compare
Type of database S201 carries out link verifying and compares two database structure difference S102S202, by the ratio of two databases
S203 can be shown in the page in table form to result.
Due to the type of database for needing to compare using selection, carries out link verifying and two database structures of comparison are poor
It is different, the comparison result of two databases can be shown in the page in table form, since the present invention encapsulates code operation,
The type of database for needing to compare need to be only selected in the page, inputted correct database connection account, also be may be selected to need
The type of database to be compared carries out link verifying, and comparison result can be shown in the page in table form, and classification is clear,
Intuitively, Excel table clearly, can also be exported, there are two functions to form first is that testing each database for technical spirit tool of the invention
It connects, second is that two database structure differences of comparison, poor it is an object of the invention to simplify database structure by a kind of method
On the one hand different contrast operation has saved resource spending in this way, on the other hand can shorten developer and test basis
Information time, realization of the invention are conducive to save development cost, simplify convention control's difference complex operations, and result information
It is intuitive and easy to understand
Described two database structure difference S102 of comparison include one basis comparison database S303 of comparison and another basis
Comparison database S303 table information, column information, index information, function information and associated database information, by two basis comparisons
Database S303 comparison result deposits in classification information database.
As shown in figure 3, two database structure difference S102 of comparison are specifically included:
Reading database S301: a basis comparison database S303 and another base are obtained by reading database S301 sentence
The corresponding table information of plinth comparison database S303, column information, index information, function information;
Replicate data library S302: comparison data table is created in classification information database, passes through replicate data library S302 language
Sentence will obtain corresponding table information, the column information, rope of a basis comparison database S303 and another basic comparison database S303
Fuse ceases, the information data of function information is stored in corresponding two comparison data tables of classification information database;
Comparison database S303: pass through corresponding two ratios of comparison database S303 sentence comparison-of-pair sorting's information database
To tables of data.
Whether the content of reading includes: the title of database, type, length, is sky, default value, annotation, major key, triggering
Device and relevant parameter.
The specific statement form of reading database S301 sentence in reading database S301 are as follows:
GET_INDEX_INFO=" SELECT UPPER (table_name) TABLE_NAME, upper (index_
Name), INDEX_NAME, GROUP_CONCAT (upper (column_name) ORDER BY SEQ_IN_INDEX) COLUMNS
FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema=?=GROUP BY TABLE_
NAME, INDEX_NAME ".
In the S302 of replicate data library, if having new data insertion, original table in classification information database is first emptied
Data.
In comparison database S303, wherein a sentence has the comparison index difference of the comparison database S303 sentence
Body statement form are as follows:
GET_DIFF_INDEX1=" select a.TABLE_NAME, a.INDEX_NAME INDEX_NAME1, ' index
There is no ' INDEX_NAME2, a.COLUMNS from t_indexinfo_1a where a.TABLE_NAME in (select
b.TABLE_NAME from t_tabinfo_2b)AND CONCAT(a.TABLE_NAME,'&',a.INDEX_NAME)not
in(select CONCAT(c.TABLE_NAME,'&',c.INDEX_NAME)from t_indexinfo_2c)”。
The reading database S301 sentence, replicate data library S302 sentence and comparison database S303 sentence are knot
Structure query language.
It is described that comparison result can be shown to include returning to list collection in the page in table form, it will be compared in the page
As a result it is rendered to table displaying, while providing and different information is exported into Excel table.
Due to using reading database: obtaining a basic comparison database by reading database sentence and another basis is right
Than the corresponding table information of database, column information, index information, function information;Replicate data library: in classification information database
Comparison data table is created, a basic comparison database and another basic comparison database will be obtained by replicate data library sentence
Corresponding table information, column information, index information, corresponding two of information data deposit classification information database of function information
Comparison data table;Comparison database: compare logarithm by corresponding two of comparison database sentence comparison-of-pair sorting's information database
According to table, comparing two database structure differences is comparison database table information, column information, index information, and function information compared
Journey needs to use three databases, basic comparison database a, basic comparison database b, storage a, b database classification information number
According to library c, it can integrally be divided into three steps:
Step 1: reading table information, the column information, index letter of a, b database by structured query language SQL statement
Breath, function information.Whether the content of reading includes: title, type, length, is sky, default value, annotation, major key, trigger etc..
Such as read index information SQL:
Table script is built step 2: executing, data table related is created in database c, passes through structured query language SQL language
Sentence by the first step operate obtained in data deposit database c in respective table.When there is new data insertion, database can be first emptied
Original table data in c, guarantee the accuracy and reliability of data.
Step 3: comparing corresponding two tables in database c in program, way of contrast is also to be realized by SQL statement:
Comparison indexes a difference wherein SQL:
GET_DIFF_INDEX1=" select a.TABLE_NAME, a.INDEX_NAME INDEX_NAME1, ' index
There is no ' INDEX_NAME2, a.COLUMNS from t_indexinfo_1a where a.TABLE_NAME in (select
b.TABLE_NAME from t_tabinfo_2b)AND CONCAT(a.TABLE_NAME,'&',a.INDEX_NAME)not
in(select CONCAT(c.TABLE_NAME,'&',c.INDEX_NAME)from t_indexinfo_2c)”。
Program returns to List set, and result is rendered to table and shown by the page, while providing different information exporting Excel
Table.
As shown in Figure 1, the method for the comparison database architectural difference further include:
Selection needs the type of database compared in the page, inputs correct database connection account and tests each database
S101S201 is connected, each database connection S101 of test includes connecting JDBC by java database to select according to the page
Type of database loads respective drive, verifies the account information of input;
If verifying is correct, establishes database connection and carry out data manipulation;
If verifying is incorrect, error message is prompted in the page;
The verifyings such as user name, password are carried out to disparate databases to execute in a browser.
Due to testing each database connection, as miscellaneous function, bottom passes through Java JDBC (Java DataBase
The connection of Connectivity, Java database) it realizes, respective drive is loaded according to the type of database of page selection, is verified defeated
The account information entered establishes database connection if correct and carries out data manipulation, in the page if account information is incorrect
Middle prompt error message.
The present invention is write by Java language, and Java is a kind of Object-Oriented Programming Language, is had good safety, is good for
Strong property, it is cross-platform the features such as, support various database manipulations.
Working principle:
This patent carries out link verifying and two database structures of comparison is poor by the type of database for selecting to need to compare
It is different, the comparison result of two databases can be shown in the page in table form, since the present invention encapsulates code operation,
The type of database for needing to compare need to be only selected in the page, inputted correct database connection account, also be may be selected to need
The type of database to be compared carries out link verifying, and comparison result can be shown in the page in table form, and classification is clear,
Intuitively, Excel table clearly, can also be exported, there are two functions to form first is that testing each database for technical spirit tool of the invention
It connects, second is that two database structure differences of comparison, the present invention solve the prior art and exist currently, database contrast difference has
Following defect: development process is at least needed to develop, be tested, formal three database environments, but in order to guarantee that database structure is united
First it needs to take a significant amount of time to be compared, goes the problem of simplifying these operations currently without unified, intuitive method, have
On the one hand resource spending has been saved, on the other hand can have shortened developer and test the basic information time, realization of the invention has
Conducive to development cost is saved, simplify convention control's difference complex operations, and the advantageous effects that result information is intuitive and easy to understand.
Using technical solution of the present invention or those skilled in the art under the inspiration of technical solution of the present invention, design
Similar technical solution out, and reach above-mentioned technical effect, it is to fall into protection scope of the present invention.