Comparison method, device and the terminal device of difference between a kind of database
Technical field
The invention belongs to the comparison method, device of difference between database technical field more particularly to a kind of database and
Terminal device.
Background technology
Database (DataBase, DB) be one be stored for a long time in it is in computer, organized, have it is shared, uniformly
The data acquisition system of management.It is a computer software for being stored and being managed data by database structure.With data
The development of library technology, database are widely used in all trades and professions, the table of multiple and different types are typically set up in database, is passed through
Each table records different data.
The service life and iteration version number of one system increase, and the data of database can also increase therewith, database
Structure may also change, therefore the comparison between different editions database is particularly important.
At present generally using ETL (Extract-Transform-Load data warehouse technologys) extractions, conversion and load number
According to different editions database to be compared, the operation of comparison procedure is cumbersome.
Therefore, it is necessary to a kind of scheme be proposed, to solve the above problems.
Invention content
In view of this, an embodiment of the present invention provides the comparison methods, device of difference between a kind of database and terminal to set
Standby, to solve the problems, such as the comparison method of difference between database in the prior art, there are cumbersome.
The first aspect of the embodiment of the present invention provides a kind of comparison method of difference between database, including:
Obtain first database and the second database and comparison information;
Acquisition difference results are compared to the first database and second database based on the comparison information
Information;
Export the difference results information.
Optionally, before obtaining first database and the second database, further include:
Judge whether the first database and second database are inter-library;
If so, establishing the connection between the first database and second database.
Optionally, the comparison information includes comparing information and/or database structure comparison information;
When the comparison information that user selects for comparing information when, based on the comparison information to the first database
Acquisition difference results information, which is compared, with second database includes:
Comparison information carries out the first database and second database ratio of each item data based on the data
It is right, obtain data difference result information;
When the comparison information that user selects for database structure comparison information when, based on the comparison information to described first
Acquisition difference results information is compared in database and second database:
Library structure comparison information carries out database to the first database and second database based on the data
The comparison of structure obtains database structure difference results information;
When the comparison information that user selects for comparing information and database structure comparison information when, be based on the comparison
Acquisition difference results information is compared to the first database and second database in information:
Comparison information based on the data carries out the first database and second database ratio of each item data
It is right, obtain data difference result information;And it is based on database structure comparison information, data are carried out to second database
The comparison of library structure obtains database structure difference results information.
Optionally, based on the comparison information to the first database and second database be compared obtain it is poor
Different result information includes:
Obtain the tables of data of the tables of data and second database of the first database;
Call structured query language SQL statement, based on the comparison information to the tables of data of the first database and
The tables of data of second database carries out additive operation, obtains differentiation information.
Optionally, the difference results information includes difference total amount, exports the difference results information and includes:
Difference total amount, every difference results information and/or SQL statement corresponding with the items difference results information are shown
Show at interface.
The second aspect of the embodiment of the present invention provides a kind of comparison device of difference between database, including:
First acquisition module, for obtaining first database and the second database and comparison information;
Second acquisition module is compared the first database and second database based on the comparison information
Obtain difference results information;
Output module, for exporting the difference results information.
Optionally, the comparison device of difference further includes between the database:
Judgment module, for judging whether the first database and second database are inter-library;
Module is established, for if so, establishing the connection between the first database and second database.
Optionally, the second acquisition module includes:
First comparing unit, for comparison information based on the data to the first database and second database
The comparison of each item data is carried out, data difference result information is obtained;
Optionally, the second acquisition module includes:
Second comparing unit, for library structure comparison information based on the data to the first database and described second
Database carries out the comparison of database structure, obtains database structure difference results information;
Optionally, the second acquisition module includes:
Third comparing unit, for comparison information based on the data, to the first database and second data
Library carries out the comparison of each item data, obtains data difference result information;And it is based on database structure comparison information, to described
Second database carries out the comparison of database structure, obtains database structure difference results information.
Optionally, second acquisition module includes:
Acquiring unit, the tables of data of tables of data and second database for obtaining the first database;
Call unit, for calling structured query language SQL statement, based on the comparison information to first data
The tables of data in library and the tables of data of second database carry out additive operation, obtain differentiation information.
Optionally, the difference results information includes difference total amount, and the output module includes:
Display unit, for by difference total amount, every difference results information and/or with every difference results information pair
The SQL statement answered is shown in interface.
The third aspect of the embodiment of the present invention provides a kind of terminal device, including memory, processor and is stored in
In the memory and the computer program that can run on the processor, when the processor executes the computer program
The step of realizing method in first aspect.
The fourth aspect of the embodiment of the present invention provides a kind of computer readable storage medium, the computer-readable storage
Media storage has computer program, when the computer program is executed by processor in realization first aspect the step of method.
In embodiments of the present invention, by obtaining first database and the second database and comparison information;Based on described
Comparison information is compared the first database and second database and obtains difference results information, exports the difference
Result information, can be based on the demand of user, i.e. different databases is compared in comparison information, in the selection of comparison information
It is upper that there is flexibility, and comparison efficiency is improved, there is stronger practicability and ease for use.
Description of the drawings
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art
Needed in attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description be only the present invention some
Embodiment for those of ordinary skill in the art without having to pay creative labor, can also be as attached such as these
Figure obtains other attached drawings.
Fig. 1 be the embodiment of the present invention one provide database between difference comparison method implementation process schematic diagram;
Fig. 2 be the preferred embodiment of the present invention provide database between difference comparison method implementation process schematic diagram;
Fig. 3 is the specific implementation flow schematic diagram of step S102 in the embodiment of the present invention one;
Fig. 4 is the structure diagram of the comparison device of difference between database provided by Embodiment 2 of the present invention.
Fig. 5 is the schematic diagram for the terminal device that the embodiment of the present invention three provides.
Specific implementation mode
In being described below, for illustration and not for limitation, it is proposed that such as tool of particular system structure, technology etc
Body details, to understand thoroughly the embodiment of the present invention.However, it will be clear to one skilled in the art that there is no these specific
The present invention can also be realized in the other embodiments of details.In other situations, it omits to well-known system, device, electricity
The detailed description of road and method, in case unnecessary details interferes description of the invention.
It should be appreciated that ought use in this specification and in the appended claims, the instruction of term " comprising " is described special
Sign, entirety, step, operation, the presence of element and/or component, but be not precluded one or more of the other feature, entirety, step,
Operation, element, component and/or its presence or addition gathered.
It is also understood that the term used in this description of the invention is merely for the sake of the mesh for describing specific embodiment
And be not intended to limit the present invention.As description of the invention and it is used in the attached claims, unless on
Other situations are hereafter clearly indicated, otherwise " one " of singulative, "one" and "the" are intended to include plural form.
It will be further appreciated that the term "and/or" used in description of the invention and the appended claims is
Refer to any combinations and all possible combinations of one or more of associated item listed, and includes these combinations.
As used in this specification and in the appended claims, term " if " can be according to context quilt
Be construed to " when ... " or " once " or " in response to determination " or " in response to detecting ".Similarly, phrase " if it is determined that "
Or " if detecting [described condition or event] " can be interpreted to mean according to context " once it is determined that " or " in response to
Determine " or " once detecting [described condition or event] " or " in response to detecting [described condition or event] ".
In order to illustrate technical solutions according to the invention, illustrated below by specific embodiment.It needs to illustrate
It is that following embodiment is applied to the system comprising filming apparatus.
Embodiment one
Fig. 1 show the embodiment of the present invention one provide database between difference comparison method implementation process signal
Figure.As shown in Figure 1, the comparison method of difference specifically may include following steps between the database:
Step S101:Obtain first database and the second database and comparison information.
Wherein, it can also be random time length that second database, which can be the upgraded version of the first database,
Two versions on two time points in period, it might even be possible to be different the database of two programs.The comparison information can
Can also be what user selected to be input by user, wherein the input mode of user can be inputted by keyboard, also may be used
Being inputted by microphone voice, other any input modes that may be implemented are can also be, then be not limited thereto;Its
In, the mode of user's selection can be that the message popped up according to dialog box selects, and can also be to be carried out according to drop-down menu
Selection, can also be other any selection modes that may be implemented, is not limited thereto.Optionally, as the embodiment of the present invention
A preferred embodiment further include as shown in Fig. 2, before obtaining first database and the second database:
Step S201:Judge whether the first database and second database are inter-library, if so, thening follow the steps
S202, if it is not, then directly acquiring first database and second database.
Illustratively, if the first database and second database belong to local data base, that is, belong to same
A terminal device, then show it is no inter-library, if in the first database and second database one belong to local data
Library, another is not belonging to local data base, it is determined that the first database and second database are inter-library.
Step S202:Then establish the connection between the first database and second database.
When being determined that the first database and second database data are inter-library in step S201, then described is established
Connection between one database and second database, such as a link (such as db_link) is established, it is linked at by this
Local library accesses remote data base, and remote data base is one in first database and second database data.
Wherein, the comparison information can be comparing information, can also be database structure comparison information, can be with
It is comparing information and database structure comparison information.Comparison information can be that user is input to interface, can also be basis
Keyword input by user, which pops up corresponding option, allows user to select, and comparison information is determined according to the clicking operation of user
Content.For example, the field name of database-name, data-base remote connection name, database table name, database table can be automatic
It matches, can choose comparison information by drop-down option in the corresponding Option Box in interface, the partial words of title can also be keyed in
Female auto-speed matches related comparison information.
It should be noted that comparison information includes but not limited to comparing information and database structure comparison information, also
It may include the comparison information of more, be not limited thereto.
Step S102:Acquisition is compared to the first database and second database based on the comparison information
Difference results information.
Optionally, based on the comparison information to the first database and second database be compared obtain it is poor
Different result information includes:
Step S301:Obtain the tables of data of the tables of data and second database of the first database.
First database and the second database are parsed respectively, obtain the tables of data and the second data of first database
The tables of data in library.
Step S302:Structured query language SQL statement is called, based on the comparison information to the first database
Tables of data and the tables of data of second database carry out additive operation, obtain differentiation information.
Wherein, structured query language SQL statement can be as follows:
The sub- SQL of #
Sql_1=" select%s from%s where%s " % (field1, tb1, cond1)
Sql_2=" select%s from%s@%s where%s " % (field2, tb2, db_link, cond2)
The total SQL of #
Sql=" select count (*) from (((%s) minus (%s)) union all ((%s) minus (%
S))) " % (sql_1, sql_2, sql_2, sql_1)
Call above-mentioned SQL statement, tables of data and second database of the comparison information to the first database
Tables of data carry out additive operation.Specifically it may include:It inquires in first database and the second database and needs the data compared
The quantity of the field of table, the attribute of title and each field, judge field quantity and field name, if all identical, judge it
Attribute, finally output are differentiated result and specific field name and its attribute, are obtained based on differentiation result and specific field name and its attribute
Obtain differentiation information.
Optionally, when the comparison information that user selects for comparing information when, based on the comparison information to described the
Acquisition difference results information is compared in one database and second database:
Comparison information carries out the first database and second database ratio of each item data based on the data
It is right, obtain data difference result information.
Wherein, the comparison of each item data may include the ratio of the comparison of database-name, the comparison of field and tables of data
It is right.
Optionally, when the comparison information that user selects for database structure comparison information when, be based on the comparison information pair
Acquisition difference results information is compared in the first database and second database:
Library structure comparison information carries out database to the first database and second database based on the data
The comparison of structure obtains database structure difference results information.
Wherein, the comparison of database structure can include but is not limited to database table, table type, table length, index, outer
The comparison of key and trigger.
Optionally, when the comparison information that user selects for comparing information and database structure comparison information when, be based on
Acquisition difference results information is compared to the first database and second database in the comparison information:
Comparison information based on the data carries out the first database and second database ratio of each item data
It is right, obtain data difference result information;And it is based on database structure comparison information, data are carried out to second database
The comparison of library structure obtains database structure difference results information.
Such case in the present embodiment, the comparing information and database structure comparison information selected according to user,
It is compared respectively, can also be to be carried out at the same time comparison, in the priority of comparison although it should be noted that be to compare respectively
Sequentially it is not construed as limiting.
Step S103:Export the difference results information.
Wherein, including the file of difference results information can be downloaded by interface.This document be include difference results information
Report is compared, can be the form of excel.
Optionally, the difference results information includes difference total amount, then exports the difference results information and include:
Difference total amount, every difference results information and/or SQL statement corresponding with the items difference results information are shown
Show at interface.
Wherein, difference total amount includes but not limited to the total amount for the field being had differences in tables of data, every difference results letter
Breath includes but not limited to the difference results information of every data difference result information and database structure.
SQL statement corresponding with the items difference results information is shown in interface and clearly corresponds to difference knot convenient for user
Fruit information and SQL statement.If in executing mistake occurs for the SQL statement, catches grab mistake from the background, the mistake of SQL syntax class is straight
It connects in the corresponding column for being illustrated in interface, in order to which user intuitively obtains wrong place and is changed accordingly.
In embodiments of the present invention, by obtaining first database and the second database and comparison information;Based on described
Comparison information is compared the first database and second database and obtains difference results information, exports the difference
Result information, can be based on the demand of user, i.e. different databases is compared in comparison information, in the selection of comparison information
It is upper that there is flexibility, and comparison efficiency is improved, there is stronger practicability and ease for use.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process
Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit
It is fixed.
Embodiment two
Referring to FIG. 4, it illustrates the structures of the comparison device of difference between database provided by Embodiment 2 of the present invention
Block diagram.The comparison device 40 of difference includes between database:First acquisition module 41, the second acquisition module 42 and output module
43.Wherein, the concrete function of each module is as follows:
First acquisition module 41, for obtaining first database and the second database and comparison information.
Second acquisition module 42 compares the first database and second database based on the comparison information
To obtaining difference results information.
Output module 43, for exporting the difference results information.
Optionally, the comparison device 40 of difference further includes between the database:
Judgment module, for judging whether the first database and second database are inter-library;
Module is established, for if so, establishing the connection between the first database and second database.
Optionally, the second acquisition module 42 includes:
First comparing unit, for comparison information based on the data to the first database and second database
The comparison of each item data is carried out, data difference result information is obtained;
Optionally, the second acquisition module 42 includes:
Second comparing unit, for library structure comparison information based on the data to the first database and described second
Database carries out the comparison of database structure, obtains database structure difference results information;
Optionally, the second acquisition module 42 includes:
Third comparing unit, for comparison information based on the data, to the first database and second data
Library carries out the comparison of each item data, obtains data difference result information;And it is based on database structure comparison information, to described
Second database carries out the comparison of database structure, obtains database structure difference results information.
Optionally, second acquisition module 42 includes:
Acquiring unit, the tables of data of tables of data and second database for obtaining the first database;
Call unit, for calling structured query language SQL statement, based on the comparison information to first data
The tables of data in library and the tables of data of second database carry out additive operation, obtain differentiation information.
Optionally, the difference results information includes difference total amount, and the output module includes:
Display unit, for by difference total amount, every difference results information and/or with every difference results information pair
The SQL statement answered is shown in interface.
In embodiments of the present invention, by obtaining first database and the second database and comparison information;Based on described
Comparison information is compared the first database and second database and obtains difference results information, exports the difference
Result information, can be based on the demand of user, i.e. different databases is compared in comparison information, in the selection of comparison information
It is upper that there is flexibility, and comparison efficiency is improved, there is stronger practicability and ease for use.
Embodiment three
Fig. 5 is the schematic diagram for the terminal device that the embodiment of the present invention three provides.As shown in figure 5, the terminal of the embodiment is set
Standby 5 include:Processor 50, memory 51 and it is stored in the meter that can be run in the memory 51 and on the processor 50
Calculation machine program 52, for example, between database difference comparison method program.The processor 50 executes the computer program 52
Step between the above-mentioned each databases of Shi Shixian in the comparison method embodiment of difference, such as step S101 shown in FIG. 1 is extremely
S103.Alternatively, the processor 50 realizes the work(of each module in above-mentioned each device embodiment when executing the computer program 52
Can, for example, module 41 to 43 shown in Fig. 4 function.
Illustratively, the computer program 52 can be divided into one or more module/units, it is one or
Multiple module/units are stored in the memory 51, and are executed by the processor 50, to complete the present invention.Described one
A or multiple module/units can be the series of computation machine program instruction section that can complete specific function, which is used for
Implementation procedure of the computer program 52 in the terminal device 5 is described.For example, the computer program 52 can be divided
It is cut into acquisition module and analysis module, the concrete function of each module is as follows:
First acquisition module, for obtaining first database and the second database and comparison information;
Second acquisition module is compared the first database and second database based on the comparison information
Obtain difference results information;
Output module, for exporting the difference results information.
The terminal device 5 can be that the calculating such as desktop PC, notebook, palm PC and cloud server are set
It is standby.The terminal device may include, but be not limited only to, processor 50, memory 51.It will be understood by those skilled in the art that Fig. 5
The only example of terminal device does not constitute the restriction to terminal device, may include components more more or fewer than diagram,
Certain components or different components are either combined, such as the terminal device can also connect including input-output equipment, network
Enter equipment, bus etc..
Alleged processor 50 can be central processing unit (Central Processing Unit, CPU), can also be
Other general processors, digital signal processor (Digital Signal Processor, DSP), application-specific integrated circuit
(Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-
Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components etc..General processor can be microprocessor or the processor can also be any conventional processor
Deng.
The memory 51 can be the internal storage unit of the terminal device 5, such as the hard disk of terminal device 5 or interior
It deposits.The memory 51 can also be to be equipped on the External memory equipment of the terminal device 5, such as the terminal device 5
Plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card dodge
Deposit card (Flash Card) etc..Further, the memory 51 can also both include the storage inside list of the terminal device 5
Member also includes External memory equipment.The memory 51 is for storing needed for the computer program and the terminal device
Other programs and data.The memory 51 can be also used for temporarily storing the data that has exported or will export.
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each work(
Can unit, module division progress for example, in practical application, can be such as needs and by above-mentioned function distribution by different work(
Energy unit, module are completed, i.e., the internal structure of described device are divided into different functional units or module, to complete above retouch
The all or part of function of stating.Each functional unit, module in embodiment can be integrated in a processing unit, can also
It is that each unit physically exists alone, can also be during two or more units be integrated in one unit, above-mentioned integrated list
The form that hardware had both may be used in member is realized, can also be realized in the form of SFU software functional unit.In addition, each functional unit,
The specific name of module is also only to facilitate mutually distinguish, the protection domain being not intended to limit this application.In above system
The specific work process of unit, module, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, is not described in detail or remembers in some embodiment
The part of load may refer to the associated description of other embodiments.
Those of ordinary skill in the art may realize that lists described in conjunction with the examples disclosed in the embodiments of the present disclosure
Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually
It is implemented in hardware or software, depends on the specific application and design constraint of technical solution.Professional technician
Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed
The scope of the present invention.
In embodiment provided by the present invention, it should be understood that disclosed device/terminal device and method, it can be with
It realizes by another way.For example, device described above/terminal device embodiment is only schematical, for example, institute
The division of module or unit is stated, only a kind of division of logic function, formula that in actual implementation, there may be another division manner, such as
Multiple units or component can be combined or can be integrated into another system, or some features can be ignored or not executed.Separately
A bit, shown or discussed mutual coupling or direct-coupling or communication connection can be by some interfaces, device
Or INDIRECT COUPLING or the communication connection of unit, can be electrical, machinery or other forms.
It is described to be converted to the unit that separating component illustrates and may or may not be physically separated, be converted to list
The component of member display may or may not be physical unit, you can be located at a place, or may be distributed over
In multiple network element.It can need to select some or all of unit therein as actual come realizing this embodiment scheme
Purpose.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it can also
It is that each unit physically exists alone, it can also be during two or more units be integrated in one unit.Above-mentioned integrated list
The form that hardware had both may be used in member is realized, can also be realized in the form of SFU software functional unit.
If the integrated module/unit, which is realized in the form of SFU software functional unit and converts, is independent product sale
Or it in use, can be stored in a computer read/write memory medium.Based on this understanding, the present invention realizes above-mentioned reality
All or part of flow in a method is applied, relevant hardware can also be instructed to complete by computer program, it is described
Computer program can be stored in a computer readable storage medium, the computer program when being executed by processor, it can be achieved that
The step of above-mentioned each embodiment of the method.Wherein, the computer program includes computer program code, the computer program
Code can be source code form, object identification code form, executable file or certain intermediate forms etc..Computer-readable Jie
Matter may include:Can carry the computer program code any entity or device, recording medium, USB flash disk, mobile hard disk,
Magnetic disc, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory (RAM,
Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that described
The content that computer-readable medium includes can carry out increase and decrease appropriate such as legislation in jurisdiction and the requirement of patent practice,
Such as in certain jurisdictions, such as legislation and patent practice, computer-readable medium does not include electric carrier signal and telecommunications letter
Number.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although with reference to aforementioned reality
Applying example, invention is explained in detail, it will be understood by those of ordinary skill in the art that:It still can be to aforementioned each
Technical solution recorded in embodiment is modified or equivalent replacement of some of the technical features;And these are changed
Or replace, the spirit and scope for various embodiments of the present invention technical solution that it does not separate the essence of the corresponding technical solution should all
It is included within protection scope of the present invention.