The content of the invention
The embodiment of the present invention provides a kind of data access method and equipment, and being deposited cash in the prior art for solution can not be to notSame type database carries out the technical problem of fragment data access.
Concrete technical scheme provided in an embodiment of the present invention is as follows:
Database access request is obtained, the database access request includes sqlid, burst field and request of dataParameter, the sqlid at least map the sql sentences of two databases;
According to the burst field and the sqlid, it is determined that at least two database tables of access are needed, described at least twoDatabase table belongs to distinct type data-base;
From the sql sentences of sqlid mappings, the sql operated at least two database table is determinedSentence;
At least two number is accessed after statement parameter in the data request parameter and the sql sentences are carried out into groupAccording to storehouse table, obtain and access result.
Optionally, when the sqlid at least maps the sql sentences of two distinct type data-bases, the sqlid and sqlSentence is one-to-many corresponding relation.
Optionally, each sql sentence corresponding to the sqlid is for single table handling of database or for for dataThe multilist in storehouse is operation associated.
Optionally, it is described according to the burst field and the sqlid, it is determined that needing to access database A, specifically include:
The burst field and the sqlid are input to default third party's program as parameter and carry out router-level topology,Obtain route results;
Determined to need at least two database tables accessed according to the route results.
Optionally, when at least two database table includes the first database table and the second database table, the basisThe burst field and the sqlid, it is determined that need after accessing at least two database tables, including:
The type of database for determining first database table is B, and determines the database of second database tableType is C, wherein, type of database B is different from type of database C.
Optionally, it is described from the sql sentences of sqlid mappings, it is determined that being carried out at least two database tableThe sql sentences of operation, are specifically included:
From the sql sentences of sqlid mappings, determine that sql sentence M corresponding with type of database B is used as to instituteState the sql sentences that the first database table is operated;
From the sql sentences of sqlid mappings, determine that sql sentence K corresponding with type of database C is used as to instituteState the sql sentences that the second database table is operated.
Optionally, the route results also include the database of first database table and second database tableAddress and physics table name, the statement parameter by the data request parameter access after carrying out group with the sql sentencesAt least two database, obtain and access result, be specially:
By the statement parameter, the sql sentences M, first database table database address and described firstFirst database table is accessed after the physics table name combination of database table, obtains and accesses result;
By the statement parameter, the sql sentences K, second database table database address and described secondSecond database table is accessed after the physics table name combination of database table, obtains and accesses result.
Optionally, the byte number of the sqlid is less than or equal to 10 bytes.
Second aspect, the embodiments of the invention provide a kind of data access equipment, including:
Access control module:For obtaining database access request, the database access request includes sqlid, dividedPiece field and data request parameter, the sqlid at least map the sql sentences of two distinct type data-bases;
Burst routing module:For according to the burst field and the sqlid, it is determined that needing to access at least two dataStorehouse table, at least two database table belong to distinct type data-base;
The access control module is additionally operable to:From the sql sentences of sqlid mappings, determine to described at least twoThe sql sentences that individual database table is operated, and the statement parameter in the data request parameter and the sql sentences are enteredAt least two database table is accessed after row group, obtains and accesses result.
Optionally, when the sqlid at least maps the sql sentences of two databases, the sqlid is one with sql sentencesTo more corresponding relations.
Optionally, each sql sentence corresponding to the sqlid is for single table handling of database or for for dataThe multilist in storehouse is operation associated.
Optionally, the burst routing module, is specifically used for:
The burst field and the sqlid are input to default third party's program as parameter and carry out router-level topology,Obtain route results;
Determined to need at least two database tables accessed according to the route results.
Optionally, when at least two database table includes the first database table and the second database table, the accessControl module, it is specifically used for:
The type of database for determining first database table is B, and determines the database of second database tableType is C, wherein, type of database B is different from type of database C.
Optionally, the access control module, is specifically used for:
From the sql sentences of sqlid mappings, determine that sql sentence M corresponding with type of database B is used as to instituteState the sql sentences that the first database table is operated;
From the sql sentences of sqlid mappings, determine that sql sentence K corresponding with type of database C is used as to instituteState the sql sentences that the second database table is operated.
Optionally, the route results also include the database of first database table and second database tableAddress and physics table name, the access control module, are specifically used for:
By the statement parameter, the sql sentences M, first database table database address and described firstFirst database table is accessed after the physics table name combination of database table, obtains and accesses result;
By the statement parameter, the sql sentences K, second database table database address and described secondSecond database table is accessed after the physics table name combination of database table, obtains and accesses result.
Optionally, the byte number of the sqlid is less than or equal to 10 bytes.
Based on above-mentioned technical proposal, in the embodiment of the present invention, acquisition database access request is employed, the database is visitedAsk that request includes sqlid, burst field and data request parameter, the sqlid at least maps two different types of dataThe sql sentences in storehouse;According to the burst field and the sqlid, it is determined that need access at least two database tables, it is described at leastTwo database tables belong to distinct type data-base;From the sql sentences of sqlid mappings, determine to described at least twoThe sql sentences that individual database table is operated;Statement parameter in the data request parameter and the sql sentences are subjected to groupAfter access at least two database table, obtain the technology for accessing result, namely in embodiments of the present invention, data accessThe sql that required parameter sqlid correspond to distinct type data-base performs sentence, is determining to need what is accessed to belong to different pieces of informationAfter the database table of storehouse type, the sql of distinct type data-base corresponding to sqlid is performed into input by sentence to corresponding databasePerformed in table, thus it is possible to effectively solve in the prior art, it is existing to carry out fragment data to distinct type data-baseThe technical problem of access, realize the technique effect accessed distinct type data-base fragment data.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present inventionIn accompanying drawing, technical scheme is clearly and completely described, it is clear that described embodiment is skill of the present inventionThe part of the embodiment of art scheme, rather than whole embodiments.It is general based on the embodiment described in file of the present invention, this areaThe every other embodiment that logical technical staff is obtained under the premise of creative work is not made, belongs to the technology of the present invention sideThe scope of case protection.
In the embodiment of the present invention, as shown in figure 1, data access process is as follows:
Step S101:Obtain database access request, the database access request include sqlid, burst field withAnd data request parameter, the sqlid at least map the sql sentences of two distinct type data-bases;
Step S102:According to the burst field and the sqlid, it is determined that needing to access at least two database tables, instituteState at least two database tables and belong to distinct type data-base;
Step S103:From the sql sentences of sqlid mappings, determine to carry out at least two database tableThe sql sentences of operation;
Step S104:Described in statement parameter in the data request parameter and the sql sentences access after groupAt least two database tables, obtain and access result.
In specific implementation process, above-mentioned steps S101 is first carried out in database access subsystem, namely obtains databaseAccess request, the database access request include sqlid, burst field and data request parameter, and the sqlid is at leastMap the sql sentences of two distinct type data-bases.
In actual applications, when needing to carry out database access, database access subsystem will be received using systemThe database access request that system is sent, the access request include sqlid, burst field and data request parameter, certainly,In actual applications, other parameters, such as database physical address can be configured in access request as needed, hereinDo not enumerate.
Marks of the sqlid as sql sentences in database access request, in embodiments of the present invention, define sqlid and reflectPenetrate the sql sentences of at least two distinct type data-bases, the sql sentences of sqlid and database are one-to-many corresponding relation,That is the corresponding at least two sql sentences of each sqlid, for example, when sqlid maps the sql sentences of two distinct type data-basesWhen, sql sentence of the sqlid difference correspondence database types for Db2 database A, and correspondence database type can be definedFor Mysql database B sql sentences;When the sql sentences of sqlid three distinct type data-bases of mapping, can defineThe sql sentences for the database A that sqlid difference correspondence database types are Db2, correspondence database type are Mysql database BSql sentences, and database C sql sentences etc. that correspondence database type is Oracle just do not list one by one herein.
In embodiments of the present invention, mapping database A, database B and database C sql languages are specifically distinguished with sqlidExemplified by sentence, the sql sentences for the database A that sqlid difference correspondence database types are Db2, correspondence database type are specifically definedFor Mysql database B sql sentences, and the sql sentences for the database C that correspondence database type is Oracle, set simultaneouslyThe byte number for putting sqlid is no more than 10 bytes, for example, the byte number that can select sqlid is 10 bytes, can also selectSqlid byte number is 5 bytes, in embodiments of the present invention, specifically so that sqlid byte number is 10 bytes as an example.
In specific implementation process, it is also an option that it is single table for database that property, which sets sql sentences corresponding to sqlid,Operation is operation associated for the multilist for database.For example, when sql sentences corresponding to selection sqlid is for databasesWhen multilist is operation associated, namely the sql sentences of database A corresponding to sqlid are operation associated for the multilist for database A,The sql sentences of database B corresponding to sqlid are operation associated for the multilist for database B, database C corresponding to sqlidSql sentences are operation associated for the multilist for database C, then, can be by sql sentences corresponding to sqlid to corresponding to itAny two tables of data in database, or more than two tables of data are associated operation.Here, specifically with sql corresponding to sqlidSentence be for a tables of data is operated in respective database exemplified by.
In actual applications, after database access subsystem receives above-mentioned database access request, database accessSubsystem carries out step S102:According to the burst field and the sqlid, it is determined that needing to access at least two databasesTable.
Fig. 2 is refer to, in actual applications, above-mentioned steps S102 can also be realized in such a way:
Rapid S1021:The burst field and the sqlid are input to default third party's program as parameter and enter walking along the streetBy calculating, route results are obtained;
Rapid S1022:Determined to need at least two database tables accessed according to the route results.
Specifically, database access subsystem can determine that the database is visited according to the database access request receivedThe sqlid, burst field and the data request parameter that include in request are asked, then, database access subsystem will call theThree equations, burst field and sqlid are then inputted into third party's program as parameter and carry out router-level topology, in practical applicationIn, third party's program can be script method, and the processing logic of the script method is realized by writing script, and advancedPerformed in the script engine of language, the mode of JavaScript scripts, script language are performed such as in java running environmentThe execution efficiency of speech is suitable with local binary code efficiency, and is easier to make for script upgrading, is figure spirit due to scriptComplete, it is thereby achieved that the various routing rule logical process of database, the support to burst route is more extensive.
In the present embodiment, specifically so that third party's program is script method as an example, then, burst field and sqlid are madeIt is input to for parameter in program corresponding to script method and carries out router-level topology, it is assumed here that route results includes at least two dataStorehouse table, then, database access subsystem can is determined to need at least two database tables accessed from route results,Certainly, in actual applications, above-mentioned router-level topology obtains route results in addition at least two database tables for needing to access,The address of at least two database tables, and database A physics table name etc. can also be included, just do not enumerated herein.
In embodiments of the present invention, the first database table and the second data are specifically included with least two database tableExemplified by the table of storehouse, then, after execution of step S102, it can also carry out step:
The type of database for determining first database table is B, and determines the database of second database tableType is C, wherein, type of database B is different from type of database C.
During concrete practice, above-mentioned first database table can be a database table, or same typeMultiple database tables of database, similarly, the second database table can be a database table, or same type dataMultiple database tables in storehouse, are not limited herein, when the first database table and second that database access subsystem needs accessAfter database table, database access subsystem will go to confirm the type of database and the second database of the first database tableThe type of database of table, in concrete practice, it can be stored in database access subsystem with the form shown in table oneThe corresponding relation of database and type of database:
Table one
| Database A | Db2 |
| Database B | Mysql |
| Database C | Oracle |
Here, suppose that, it is necessary to which the first database table accessed is table in database A, the second database table is in database BTable, then, according to table one, database access subsystem can determine that the type of database of the first database table is speciallyDb2, the type of database for determining the second database table are specially Mysql.
Afterwards, the method in the present embodiment carries out step S103:From the sql sentences of sqlid mappings, it is determined thatGo out the sql sentences operated at least two database table.
Fig. 3 is refer to, in actual applications, step S103 can also be realized in such a way:
Step S1031:From the sql sentences of sqlid mappings, sql sentences corresponding with type of database B are determinedM is as the sql sentences operated to first database table;
Step S1032:From the sql sentences of sqlid mappings, sql sentences corresponding with type of database C are determinedK is as the sql sentences operated to second database table.
Specifically, determining that the type of database of the first database table is Db2 in database access subsystem, is determinedAfter the type of database of two database tables is Mysql, database access subsystem will be from the sql languages that sqlid maps respectivelySql sentences corresponding with type of database Db2 are determined in sentence as the sql sentences operated to the first database table, withAnd determine sql sentences corresponding with type of database Mysql as the sql sentences operated to the second database table.ThisIn, it is assumed that the configuration of the database A that sqlid maps respectively, database B and database C sql sentences is as follows:
Sqlid.testId.db2=values (current timestamp)
Sqlid.testId.mysql=select now ()
Sqlid.testId.oracle=select systimestamp from dual
So, database access subsystem will select sql sentences corresponding to type of database Db2 from above-mentioned configurationThat is values (current timestamp), as the sql sentences operated to the first database table, selects class databaseSql sentences corresponding to type Mysql namely select now (), as the sql sentences operated to the second database table.
After method execution of step S103 in the present embodiment, step S104 is carried out:By the request of dataStatement parameter in parameter accesses at least two database table after carrying out group with the sql sentences, obtains and accesses result.
In actual applications, in above-mentioned steps S102, if burst field and sqlid are being input into script as parameterRouter-level topology is carried out in program corresponding to method, obtaining route results also includes first database table and second numberAccording to the database address and physics table name of storehouse table, then, step S103 can also be performed in such a way:
Step A:By the statement parameter, the sql sentences M, the database address of first database table and instituteFirst database table is accessed after stating the physics table name combination of the first database table, obtains and accesses result;
Step B:By the statement parameter, the sql sentences K, the database address of second database table and instituteSecond database table is accessed after stating the physics table name combination of the second database table, obtains and accesses result.
That is, also include the database address and physics table name of the first database table in above-mentioned route results, describedWhen the database address and physics table name of two database tables, database access subsystem will be by the first number in route resultsAccording to the database address of storehouse table, physics table name, sql sentences corresponding to the statement parameter and type Db2 in request of data are carried outCombination, the parameter after combination as the first database table of access, database access subsystem is by the second data in route resultsThe database address of storehouse table, physics table name, sql sentences are carried out corresponding to the statement parameter and type Mysql in request of dataCombination, as the parameter for accessing the second database table after combination, obtain and access result, then will access result and be output to databaseIn system.
So by the above method, the present invention uses sqlid using the required parameter of data access, and data access is askedAsk parameter sqlid to correspond to the sql of distinct type data-base and perform sentence, determining to need what is accessed to belong to disparate databasesAfter the database table of type, the sql of distinct type data-base corresponding to sqlid is performed into input by sentence to corresponding database tableMiddle execution, thus it is possible to effectively solve in the prior art, it is existing to carry out fragment data visit to distinct type data-baseThe technical problem asked, realize the technique effect accessed distinct type data-base fragment data.
In addition, the present invention uses sqlid using the required parameter of data access so that will not in the message of data access requestThere is the information of table and field in database, avoid the time-consuming operation for accessing database table, thus it is possible to effectively solve existingHave in technology, the low technical problem of fragment data access efficiency be present.The beneficial effect of fragment data access efficiency with raisingFruit.
Again because sql language corresponding to sqlid in embodiments of the invention can be two tables or multilist for databaseIt is operation associated, it is achieved that the burst route of database multi-list associated data operation.Due to traditional database be for table andAction type carries out control of authority, and the embodiment of the present invention carries out data access using sqlid mode, can be by each sqlSentence operation carries out control of authority, so, control of authority dynamics is thinner than traditional database, meanwhile, the request of database accessParameter uses sqlid rather than sql sentences, is not in table and field in database in such database access request messageInformation, also play the effect to database structure protection.
In addition, parameter directly uses sql sentences using sqlid in the request of database access, and sqlid uses do not surpass10 bytes are crossed, well below network traffics required when using sql sentences as parameter, so, also save network requestFlow.The embodiment of the present invention uses script method, and as third party's program, script is in the running environment of high-level languagePortion performs, and the computational efficiency of burst route is higher, so, further increase the efficiency that fragment data accesses.
Based on same inventive concept, a kind of data access equipment is provided in the embodiment of the present invention, the device data accessesSpecific implementation can be found in embodiment of the method part description, repeat part repeat no more, as shown in figure 4, the equipment is mainly wrappedInclude:
Access control module 11:For obtaining database access request, the database access request include sqlid,Burst field and data request parameter, the sqlid at least map the sql sentences of two distinct type data-bases;
Burst routing module 12:For according to the burst field and the sqlid, it is determined that needing to access at least two numbersAccording to storehouse table;
The access control module 11 is additionally operable to:From the sqlid mapping sql sentences in, determine to it is described at leastThe sql sentences that two database tables are operated, and by the statement parameter in the data request parameter and the sql sentencesAt least two database table is accessed after carrying out group, obtains and accesses result.
Optionally, when the sqlid at least maps the sql sentences of two databases, the sqlid is one with sql sentencesTo more corresponding relations.
Optionally, each sql sentence corresponding to the sqlid is for single table handling of database or for for dataThe multilist in storehouse is operation associated.
Optionally, the burst routing module, is specifically used for:
The burst field and the sqlid are input to default third party's program as parameter and carry out router-level topology,Obtain route results;
Determined to need at least two database tables accessed according to the route results.
Optionally, when at least two database table includes the first database table and the second database table, the accessControl module, it is specifically used for:
The type of database for determining first database table is B, and determines the database of second database tableType is C, wherein, type of database B is different from type of database C.
Optionally, the access control module, is specifically used for:
From the sql sentences of sqlid mappings, determine that sql sentence M corresponding with type of database B is used as to instituteState the sql sentences that the first database table is operated;
From the sql sentences of sqlid mappings, determine that sql sentence K corresponding with type of database C is used as to instituteState the sql sentences that the second database table is operated.
Optionally, the route results also include the database of first database table and second database tableAddress and physics table name, the access control module, are specifically used for:
By the statement parameter, the sql sentences M, first database table database address and described firstFirst database table is accessed after the physics table name combination of database table, obtains and accesses result;
By the statement parameter, the sql sentences K, second database table database address and described secondSecond database table is accessed after the physics table name combination of database table, obtains and accesses result.
Optionally, the byte number of the sqlid is less than or equal to 10 bytes.
In addition, in data access equipment in embodiments of the present invention, it is managed collectively to database access,All sql sentences are all managed concentratedly in access control module, therefore, are easy to DBA to be managed collectively, are more optimized dataStorehouse is accessed, and routing rule is easy to modifications and extensions, and routing rule is disposed independently of Data access module, after routing rule modification notThe whole module of data access is needed to be upgraded.
Based on same inventive concept, the embodiments of the invention provide a kind of data access equipment, the specific implementation of the equipmentReference can be made to the description of embodiment of the method part, repeats part and repeats no more, as shown in figure 5, the equipment mainly includes processor 21With the He of memory 22, wherein, preserve default program in memory 22, processor 21 reads the program in memory 22, pressesProcedure below is performed according to the program:
Database access request is obtained, the database access request includes sqlid, burst field and request of dataParameter, the sqlid at least map the sql sentences of two distinct type data-bases;
According to the burst field and the sqlid, it is determined that needing to access at least two databases;
From the sql sentences of sqlid mappings, the sql languages operated at least two database are determinedSentence;
At least two number is accessed after statement parameter in the data request parameter and the sql sentences are carried out into groupAccording to storehouse, obtain and access result.
Optionally, when the sqlid at least maps the sql sentences of two databases, the sqlid is one with sql sentencesTo more corresponding relations.
Optionally, each sql sentence corresponding to the sqlid is for single table handling of database or for for dataThe multilist in storehouse is operation associated.
Optionally, it is described according to the burst field and the sqlid, it is determined that needing to access at least two databases, toolBody includes:
The burst field and the sqlid are input to default third party's program as parameter and carry out router-level topology,Obtain route results;
Determined to need at least two databases accessed according to the route results.
Optionally, when at least two database table includes the first database table and the second database table, the accessControl module, it is specifically used for:
The type of database for determining first database table is B, and determines the database of second database tableType is C, wherein, type of database B is different from type of database C.
Optionally, the access control module, is specifically used for:
From the sql sentences of sqlid mappings, determine that sql sentence M corresponding with type of database B is used as to instituteState the sql sentences that the first database table is operated;
From the sql sentences of sqlid mappings, determine that sql sentence K corresponding with type of database C is used as to instituteState the sql sentences that the second database table is operated.
Optionally, the route results also include the database of first database table and second database tableAddress and physics table name, the access control module, are specifically used for:
By the statement parameter, the sql sentences M, first database table database address and described firstFirst database table is accessed after the physics table name combination of database table, obtains and accesses result;
By the statement parameter, the sql sentences K, second database table database address and described secondSecond database table is accessed after the physics table name combination of database table, obtains and accesses result.
Optionally, the byte number of the sqlid is less than or equal to 10 bytes.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or computer programProduct.Therefore, the present invention can use the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardwareApply the form of example.Moreover, the present invention can use the computer for wherein including computer usable program code in one or moreThe shape for the computer program product that usable storage medium is implemented on (including but is not limited to magnetic disk storage and optical memory etc.)Formula.
The present invention is the flow with reference to method according to embodiments of the present invention, equipment (system) and computer program productFigure and/or block diagram describe.It should be understood that can be by every first-class in computer program instructions implementation process figure and/or block diagramJourney and/or the flow in square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be providedThe processors of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produceA raw machine so that produced by the instruction of computer or the computing device of other programmable data processing devices for realThe device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing devices with spyDetermine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which produces, to be included referring toMake the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram orThe function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that countedSeries of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, so as in computer orThe instruction performed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram oneThe step of function of being specified in individual square frame or multiple square frames.
Obviously, those skilled in the art can carry out the essence of various changes and modification without departing from the present invention to the present inventionGod and scope.So, if these modifications and variations of the present invention belong to the scope of the claims in the present invention and its equivalent technologiesWithin, then the present invention is also intended to comprising including these changes and modification.