CN102073490B - Method and device for translating database language - Google Patents

Method and device for translating database language Download PDF

Info

Publication number
CN102073490B
CN102073490B CN 200910246314 CN200910246314A CN102073490B CN 102073490 B CN102073490 B CN 102073490B CN 200910246314 CN200910246314 CN 200910246314 CN 200910246314 A CN200910246314 A CN 200910246314A CN 102073490 B CN102073490 B CN 102073490B
Authority
CN
China
Prior art keywords
sql
database
source
code
key word
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN 200910246314
Other languages
Chinese (zh)
Other versions
CN102073490A (en
Inventor
杨柏刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN 200910246314 priority Critical patent/CN102073490B/en
Publication of CN102073490A publication Critical patent/CN102073490A/en
Priority to HK11107091.0A priority patent/HK1153017A1/en
Application granted granted Critical
Publication of CN102073490B publication Critical patent/CN102073490B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The embodiment of the invention discloses a method and a device for translating database language; a method for pre-setting and storing the translation logic comprises the following steps: acquiring source SQL (Structured Query Language) code, source SQL database type and object SQL database type; compiling the source SQL code, acquiring the key word and the grammar logic in the source SQL code; searching the translation logic according to the source SQL database type and the object SQL database type, acquiring the key word and the grammar logic in the object SQL database corresponding to thecompiled key word and grammar logic; and acquiring other codes in the key word and the source SQL code except the key word according to the grammar logic composition in the object SQL database, and generating the object SQL code. The source SQL code can be automatically translated into the object SQL code according to the translation logic, thereby improving the developing efficiency of the database and reducing the load of the developer.

Description

Method and the device of translation data storehouse language
Technical field
The application relates to field of computer technology, relates in particular to method and the device of a kind of translation data storehouse language.
Background technology
SQL (Structured Query Language, Structured Query Language (SQL)) is a kind of data base querying and programming language, is used for access data and inquiry, renewal and administrative relationships Database Systems.The kind of the database in the existing internet is numerous, for example, the Greenplum database that is used for log processing, be used for the Teradata database of business datum etc., when select adopting which kind of database, usually need integrated data demand and cost accounting etc. to carry out the selection of database, and for the data of different types storehouse, its corresponding sql like language that uses also inequality.
In research and practice process to prior art, the inventor finds to exist in the prior art following problem: often the database development personnel are proficient in the database language of a certain type, and write sql like language at the type database, but when business demand changes, may need to develop the database that uses other type, at this moment because variation has taken place in type of database, originally the sql like language of writing has not been suitable for the database after the variation, cause the developer to write sql like language again to new database, reduce the development efficiency of database thus, increased developer's burden.Prior art also exists by middle script realization sql like language translating between distinct type data-base, but the prior art need be carried out the code of a large amount of middle scripts and be write, and in the process of translating, need to read a sql like language, finish translating of a sql like language then, therefore, it is low to translate speed.
Summary of the invention
The purpose of the embodiment of the present application provides method and the device of a kind of translation data storehouse language, can't be general between disparate databases to solve existing sql like language, and the problem that causes database development efficient to reduce.
For solving the problems of the technologies described above, the embodiment of the present application provides the method for a kind of translation data storehouse language, is achieved in that
The method of a kind of translation data storehouse language, set in advance and preserve translation logic, comprise the corresponding relation between the key word of the same race of different SQL database in the described translation logic, and the corresponding relation between the grammer logic of the same race of different SQL database, described method comprises:
Obtain source SQL code, source SQL database type and purpose SQL database type;
Compile described source SQL code, obtain key word and grammer logic in the SQL code of described source;
Search described translation logic according to described source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the corresponding purpose SQL database of the key word that obtains with described compiling and grammer logic;
According to other code except key word in the described key word that obtains of the grammer logical combination in the described purpose SQL database and the described source SQL code, generate purpose SQL code.
For solving the problems of the technologies described above, the embodiment of the present application also provides the device of a kind of translation data storehouse language, is achieved in that
The device of a kind of translation data storehouse language comprises:
Preserve the unit, be used for setting in advance and preserve translation logic, comprise the corresponding relation between the key word of the same race of different SQL database in the described translation logic, and the corresponding relation between the grammer logic of the same race of different SQL database;
Acquiring unit is used for obtaining source SQL code, source SQL database type and purpose SQL database type;
Compilation unit is used for the described source of compiling SQL code, obtains key word and grammer logic in the SQL code of described source;
Search the unit, be used for searching described translation logic according to described source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the corresponding purpose SQL database of the key word that obtains with described compiling and grammer logic;
Translate the unit, be used for according to other code except key word in the described key word that obtains of the grammer logical combination of described purpose SQL database and the described source SQL code, generate purpose SQL code.
As seen, set in advance and preserved translation logic in the embodiment of the present application, when obtaining source SQL code, after source SQL database type and the purpose SQL database type, compiling source SQL code obtains key word and the grammer logic in the SQL code of source, search translation logic according to source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the purpose SQL database corresponding with compiling the key word that obtains and grammer logic, other code in the key word that obtains according to the grammer logical combination in the purpose SQL database and the source SQL code except key word generates purpose SQL code.In the embodiment of the present application owing to set in advance the translation logic of key word and grammer logic, therefore for the SQL code between the disparate databases, can source SQL code be translated into purpose SQL code automatically according to these translation logic, and, because the application can read source SQL code in batches and translate automatically in batches, therefore, the speed of translating is quick, the efficient height.In addition, the application need not the developer and writes purpose SQL code again, has improved the development efficiency of database thus, has alleviated developer's burden.
Description of drawings
In order to be illustrated more clearly in the embodiment of the present application or technical scheme of the prior art, to do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art below, apparently, the accompanying drawing that describes below only is some embodiment that put down in writing among the application, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the first embodiment process flow diagram of the method for the application's translation data storehouse language;
Fig. 2 is the second embodiment process flow diagram of the method for the application's translation data storehouse language;
Fig. 3 develops the process flow diagram of compiling transfer interpreter and application thereof for the application;
Fig. 4 is the first embodiment block diagram of the application's translation data storehouse device;
Fig. 5 is the second embodiment block diagram of the application's translation data storehouse device.
Embodiment
The embodiment of the present application provides method and the device of a kind of translation data storehouse language.
In order to make those skilled in the art person understand technical scheme in the embodiment of the present application better, and the above-mentioned purpose of the embodiment of the present application, feature and advantage can be become apparent more, below in conjunction with accompanying drawing technical scheme in the embodiment of the present application is described in further detail.
Heterogeneous database system is the set of a plurality of Database Systems of being correlated with, can realize sharing and transparent access of data, each Database Systems itself just existed before adding heterogeneous database system, the DBMS (Database Management System, data base management system (DBMS)) that has oneself.Each ingredient of heterogeneous database has the autonomy of self, when realizing data sharing, each Database Systems is still possessed the application characteristic of oneself, integrity control and security control, and, different databases has nothing in common with each other to the degree of support of SQL grammer, that is to say, need use different SQL codes during the visit disparate databases, because writing the SQL code for disparate databases will greatly increase database development personnel's work, and when database corresponding service demand changes when causing database to change, then need to readjust the SQL code of all disparate databases; For the enterprise database developer, often only be proficient in writing of a certain database SQL code, and can not be proficient in writing of all database SQL codes in the heterogeneous database system, therefore need be proficient in a plurality of database development personnel that disparate databases SQL code is write, also can increase the cost of enterprise thus.
Comprehensively above-mentioned, the embodiment of the present application is to realize to stride the exploitation of the SQL code of heterogeneous database, by identifying a kind of SQL code of database, and the translation logic by setting in advance, this database SQL code is translated to the SQL code of the another kind of database of appointment automatically, to save database development personnel's work.
Referring to Fig. 1, be the first embodiment process flow diagram of the method for the application's translation data storehouse language:
Step 101: set in advance and preserve translation logic.
Comprise the corresponding relation between the key word of the same race of different SQL database in the translation logic, and the corresponding relation between the grammer logic of the same race of different SQL database.
SQL code for any database, it has fixing key word, the for example select in the oracle database, where, while etc., though and these key words have identical function in other database, but form may change to some extent, therefore the corresponding relation between the key word of the function of the same race in these disparate databases need be preserved.
Comprise negligible character string in the common SQL statement, for example: space, carriage return, newline etc., also comprise above-mentioned key word and with some comment entries etc., the SQL statement that is connected in series by above-mentioned different key words has the fixedly syntactic structure of its correspondence, namely by grammer and the grammer logic of forming of moving, and disparate databases may be different for the grammer logic of the SQL statement of function of the same race, therefore also need the corresponding relation between the grammer logic of the SQL statement of the function of the same race in these disparate databases is preserved.
Step 102: obtain source SQL code, source SQL database type and purpose SQL database type.
In order to realize the conversion of SQL code; usually can develop one and translate application interface; can receive the source SQL code of developer's input by this interface; just can judge SQL database type under the SQL code of this source according to some key words in the SQL code of source or grammer logic; perhaps directly imported the type of SQL database by the developer; above-mentioned type of database is as source SQL database type, and can receive the purpose SQL database type of developer's input simultaneously.
Will by application interface obtain source SQL code, source SQL database type and destination data storehouse type preserve, to carry out the follow-up operation of translating.Present embodiment can obtain all SQL statement in the SQL code of source in batches in the process of translating, so that the follow-up batch that can finish SQL statement is automatically translated.
Type of database in the heterogeneous database system that the embodiment of the present application is used can comprise: Postgress database, Mysql database, Sqlserver database, oracle database, informix database, sybase database, Db2 database.Certainly, the embodiment of the present application also can be not limited to above-mentioned database, when new type of database, and can be by upgrading the content of translation logic, add key word and the grammer logic of this new type of database, the type of database that this is new is included the scope that the application translates in.
Step 103: compiling source SQL code obtains key word and grammer logic in the SQL code of source.
Usually, can set in advance morphology file and grammar file in the system, the key word that comprises different SQL database in the morphology file, comprise the grammer logic that reads rule and correspondence of different key words in the grammar file, all grammar files of heterogeneous database and morphology file can be arranged in the file and preserve.
The process of compiling is exactly the rule that reads according to source SQL database type correspondence in the above-mentioned grammar file, the process that each bar SQL statement in the SQL code of source is analyzed, in the process of analyzing, can order from the beginning read each character, extract key word according to positions such as space, carriage returns, by analyzing the key word to obtain in this SQL code, and obtain and the corresponding grammer logic of extraction key word.
Step 104: search translation logic according to source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the purpose SQL database corresponding with compiling the key word that obtains and grammer logic.
Key word and grammer logic according to the source SQL code that extracts, search the corresponding relation in the translation logic of preserving in advance, obtain the key word of the purpose SQL code corresponding with key word in the SQL code of source, and the grammer logic of the purpose SQL code corresponding with the grammer logic of source SQL code.
Step 105: other code in the key word that obtains according to the grammer logical combination in the purpose SQL database and the source SQL code except key word, generate purpose SQL code, finish current flow process.
The embodiment of the present application can be translated automatically to the statement in the many source SQL codes that get access to, thereby improves the speed of translating of SQL statement.
Referring to Fig. 2, be the second embodiment process flow diagram of the method for the application's translation data storehouse language:
Step 201: set in advance and preserve translation logic.
Comprise the corresponding relation between the key word of the same race of different SQL database in the translation logic, and the corresponding relation between the grammer logic of the same race of different SQL database.
SQL code for any database, it has fixing key word, the for example select in the oracle database, where, while etc., though and these key words have identical function in other database, but form may change to some extent, therefore the corresponding relation between the key word of the function of the same race in these disparate databases need be preserved.
Comprise negligible character string in the common SQL statement, for example: space, carriage return, newline etc., also comprise above-mentioned key word and with some comment entries etc., the SQL statement that is connected in series by above-mentioned different key words has the fixedly syntactic structure of its correspondence, namely by grammer and the grammer logic of forming of moving, and disparate databases may be different for the grammer logic of the SQL statement of function of the same race, therefore also need the corresponding relation between the grammer logic of the SQL statement of the function of the same race in these disparate databases is preserved.
Step 202: set in advance morphology file and grammar file.
The key word that comprises different SQL database in the morphology file, what comprise different key words in the grammar file reads rule and corresponding grammer logic, and all grammar files of heterogeneous database and morphology file can be arranged in the file and preserve.
Step 203: receive the source SQL code by the application interface input.
Step 204: according to the SQL database type under the content judgement source SQL code of source SQL code, as source SQL database type.
Step 205: receive the purpose SQL database type of selecting by application interface.
Step 206: read content corresponding with described source SQL database type in morphology file and the grammar file.
Step 207: according to the rule analysis source of the reading SQL code that comprises in the content that reads, the key word of extraction source SQL code and corresponding grammer logic.
Step 208: search translation logic according to source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the purpose SQL database corresponding with compiling the key word that obtains and grammer logic.
Key word and grammer logic according to the source SQL code that extracts, search the corresponding relation in the translation logic of preserving in advance, obtain the key word of the purpose SQL code corresponding with key word in the SQL code of source, and the grammer logic of the purpose SQL code corresponding with the grammer logic of source SQL code.
Step 209: other code in the key word that obtains according to the grammer logical combination in the purpose SQL database and the source SQL code except key word, generate purpose SQL code, finish current flow process.
In addition, when adding new database SQL type, can upgrade the translation logic of preserving in advance, increase the key word of new database SQL and the key word of already present each database SQL of grammer logical and and the corresponding relation of grammer logic and get final product.
Above-mentioned the embodiment of the present application realize SQL code between the heterogeneous database translate exploitation the time, can use SQL developing instrument platform (SQL Developer), adopt JAVA to write the compiling transfer interpreter of realizing heterogeneous database SQL code conversion, when using, call this compiling transfer interpreter and get final product.The process of above-mentioned exploitation compiling transfer interpreter and application thereof is as shown in Figure 3:
Step 301: write grammar file and the morphology file (ALLSQL.jj) at all database SQLs that meet the javacc grammer.
Morphology file and grammar file can be programmed in the Javacc file, and this document consists of the following components:
The Option option: this part need not specify when writing the ALLSQL.jj file, can use the option option of acquiescence.
The statement of analyzer class: class name is called ALLSQL.
Morphology is partly stated: comprise SKIP, TOKEN, SPECIAL_TOKEN, MORE.
Wherein, SKIP is used for the negligible character string of explanation, for SQL, and the negligible character string basically identical of its negligible character string and other Languages, for example space, TAB key, carriage return, newline etc.;
The key word of all databases that TOKEN is used for illustrating that SQL comprises, for example alter, commit, roback, for, while etc.;
SPECIAL_TOKEN mainly is that the TOKEN of the character string of comment entry describes.
The grammer statement: (what can not derive is terminal symbol to each nonterminal symbol in the grammer again usually, can derive for nonterminal symbol) corresponding functions all, for SQL, nonterminal symbol is a lot, all is nonterminal symbol such as ProcedureDeclaration, procedurebody, for, while, if, cursor etc.
Step 302: morphology file and grammar file are generated corresponding java code by javacc.
Resolve the java source code file that the ALLSQL.jj file just can generate morphology file and grammar file by javacc, the java source code file comprises:
ALLSQL.java
ALLSQLConstants.java
ALLSQLTokenManager.java
JavaCharStream.java
ParseException.java
Token.java
TokenMgrError.java
Step 303: write the java code that a kind of database SQL is translated into the translation logic of other database SQL.
Need to prove that this step 303 can be carried out synchronously with abovementioned steps 301 and step 302, its execution result is input to step 304 simultaneously.
Translating code mainly is at the ability that every kind of database SQL is translated into other database SQL, such as: the decode in the oracle database is translated into case in the postgres database, when statement etc., gives an example no longer one by one at this.
At the nonterminal symbol of each SQL statement the interface function of corresponding disparate databases can be arranged all in when design, just the character before the SQL statement nonterminal symbol is translated into the SQL character of which kind of database, for example:
toOracle()
toPostgres()
toDb2()
toSqlServer()
toSybase()
toInformax()
Certainly, also can expand the interface function of other database except above-mentioned database according to the type of database that will translate.
Step 304: generate a class file by above-mentioned all the java codes of java compiling.
The java source code that generates in above-mentioned steps 302 and the step 303 is compiled as binary class (class) file by javacc; Also the class file that can pack all by java-jar is a jar bag, adds this jar bag and just can use in the catalogue of application interface.
Step 305: in application interface, realize calling this class file when translating, finish current flow process.
When translating, the compiling of in application interface, calling above-mentioned generation with translate class file, source SQL character string or file are translated operation, wherein interface application can be based on the program of web, client-based program, or based on the program on backstage.
Corresponding with the embodiment of the method for the application's translation data storehouse language, the application also provides the embodiment of the device of translation data storehouse language.
Referring to Fig. 4, be the first embodiment block diagram of the device of the application's translation data storehouse language:
This device comprises: preserve unit 410, acquiring unit 420, compilation unit 430, search unit 440 and translate unit 450.
Wherein, preserve unit 410, be used for setting in advance and preserve translation logic, comprise the corresponding relation between the key word of the same race of different SQL database in the described translation logic, and the corresponding relation between the grammer logic of the same race of different SQL database;
Acquiring unit 420 is used for obtaining source SQL code, source SQL database type and purpose SQL database type;
Compilation unit 430 is used for the described source of compiling SQL code, obtains key word and grammer logic in the SQL code of described source;
Search unit 440, be used for searching described translation logic according to described source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the corresponding purpose SQL database of the key word that obtains with described compiling and grammer logic;
Translate unit 450, be used for according to other code except key word in the described key word that obtains of the grammer logical combination of described purpose SQL database and the described source SQL code, generate purpose SQL code.
Referring to Fig. 5, be the second embodiment block diagram of the device of the application's translation data storehouse language:
This device comprises: preserve unit 510, default unit 520, acquiring unit 530, compilation unit 540, search unit 550, translate unit 560 and updating block 570.
Wherein, preserve unit 510, be used for setting in advance and preserve translation logic, comprise the corresponding relation between the key word of the same race of different SQL database in the described translation logic, and the corresponding relation between the grammer logic of the same race of different SQL database;
Default unit 520 is used for setting in advance morphology file and grammar file, comprises the key word of different SQL database in the described morphology file; The grammer logic that reads rule and correspondence that comprises different key words in the described grammar file;
Acquiring unit 530 is used for obtaining source SQL code, source SQL database type and purpose SQL database type;
Compilation unit 540 is used for the described source of compiling SQL code, obtains key word and grammer logic in the SQL code of described source;
Search unit 550, be used for searching described translation logic according to described source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the corresponding purpose SQL database of the key word that obtains with described compiling and grammer logic;
Translate unit 560, be used for according to other code except key word in the described key word that obtains of the grammer logical combination of described purpose SQL database and the described source SQL code, generate purpose SQL code;
Updating block 570 is used for upgrading described translation logic when the new database SQL type of adding, increases key word and the key word of already present each database SQL of grammer logical and and the corresponding relation of grammer logic of described new database SQL.
Concrete, acquiring unit 530 can comprise (not shown among Fig. 5):
The source code receiving element is used for receiving the source SQL code by the application interface input;
The Source Type judging unit is used for judging SQL database type under the SQL code of described source according to the content of described source SQL code, as source SQL database type;
Purpose type receiving element is used for receiving the purpose SQL database type of selecting by application interface.
Concrete, compilation unit 540 can comprise (not shown among Fig. 5):
Document reading unit is used for reading described morphology file and the grammar file content corresponding with described source SQL database type;
Information extraction unit for the described source of rule analysis of the reading SQL code that comprises according to the described content that reads, is extracted key word and the corresponding grammer logic of described source SQL code.
As seen through the above description of the embodiments, set in advance and preserved translation logic in the embodiment of the present application, when obtaining source SQL code, after source SQL database type and the purpose SQL database type, compiling source SQL code obtains key word and the grammer logic in the SQL code of source, search translation logic according to source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the purpose SQL database corresponding with compiling the key word that obtains and grammer logic, other code in the key word that obtains according to the grammer logical combination in the purpose SQL database and the source SQL code except key word generates purpose SQL code.In the embodiment of the present application owing to set in advance the translation logic of key word and grammer logic, therefore for the SQL code between the disparate databases, can source SQL code be translated into purpose SQL code automatically according to these translation logic, and, because the application can read source SQL code in batches and translate automatically in batches, therefore, the speed of translating is quick, the efficient height.In addition, the application need not the developer and writes purpose SQL code again, has improved the development efficiency of database thus, has alleviated developer's burden.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the application and can realize by the mode that software adds essential general hardware platform.Based on such understanding, the part that the application's technical scheme contributes to prior art in essence in other words can embody with the form of software product, this computer software product can be stored in the storage medium, as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are with so that a computer equipment (can be personal computer, server, the perhaps network equipment etc.) carry out the described method of some part of each embodiment of the application or embodiment.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, and identical similar part is mutually referring to getting final product between each embodiment, and each embodiment stresses is difference with other embodiment.Especially, for system embodiment, because it is substantially similar in appearance to method embodiment, so description is fairly simple, relevant part gets final product referring to the part explanation of method embodiment.
The application can be used in numerous general or special purpose computingasystem environment or the configuration.For example: personal computer, server computer, handheld device or portable set, plate equipment, multicomputer system, the system based on microprocessor, set top box, programmable consumer-elcetronics devices, network PC, small-size computer, mainframe computer, comprise distributed computing environment of above any system or equipment etc.
The application can describe in the general context of the computer executable instructions of being carried out by computing machine, for example program module.Usually, program module comprises the routine carrying out particular task or realize particular abstract data type, program, object, assembly, data structure etc.Also can in distributed computing environment, put into practice the application, in these distributed computing environment, be executed the task by the teleprocessing equipment that is connected by communication network.In distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium that comprises memory device.
Though described the application by embodiment, those of ordinary skills know, the application has many distortion and variation and the spirit that do not break away from the application, wish that appended claim comprises these distortion and variation and the spirit that do not break away from the application.

Claims (8)

1. the method for a translation data storehouse language, it is characterized in that, set in advance and preserve translation logic, comprise the corresponding relation between the key word of the same race of different SQL database in the described translation logic, and the corresponding relation between the grammer logic of the same race of different SQL database; Set in advance morphology file and grammar file, comprise the key word of different SQL database in the described morphology file, comprise the grammer logic that reads rule and correspondence of different key words in the described grammar file, described method comprises:
Obtain source SQL code, source SQL database type and purpose SQL database type;
Read content corresponding with described source SQL database type in described morphology file and the grammar file;
According to the described source of rule analysis of the reading SQL code that comprises in the described content that reads, extract key word and the corresponding grammer logic of described source SQL code;
Search described translation logic according to described source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the corresponding purpose SQL database of the key word that obtains with described compiling and grammer logic;
According to other code except key word in the described key word that obtains of the grammer logical combination in the described purpose SQL database and the described source SQL code, generate purpose SQL code.
2. method according to claim 1 is characterized in that, described source SQL database type, purpose SQL database type and the source SQL code of obtaining comprises:
Reception is by the source SQL code of application interface input;
Judge SQL database type under the SQL code of described source according to the content of described source SQL code, as source SQL database type;
The purpose SQL database type that reception is selected by application interface.
3. method according to claim 1 and 2, it is characterized in that described SQL database type comprises: Postgress database, Mysql database, Sqlserver database, oracle database, informix database, sybase database, Db2 database.
4. method according to claim 1 is characterized in that, described morphology file and grammar file are specially based on the grammar file of JAVACC and morphology file;
The translation logic of described translation logic for writing based on JAVA.
5. method according to claim 1, it is characterized in that, also comprise: when adding new database SQL type, upgrade described translation logic, increase key word and the key word of already present each database SQL of grammer logical and and the corresponding relation of grammer logic of described new database SQL.
6. the device of a translation data storehouse language is characterized in that, comprising:
Preserve the unit, be used for setting in advance and preserve translation logic, comprise the corresponding relation between the key word of the same race of different SQL database in the described translation logic, and the corresponding relation between the grammer logic of the same race of different SQL database; Set in advance morphology file and grammar file, comprise the key word of different SQL database in the described morphology file, comprise the grammer logic that reads rule and correspondence of different key words in the described grammar file;
Acquiring unit is used for obtaining source SQL code, source SQL database type and purpose SQL database type;
Compilation unit is used for reading described morphology file and the grammar file content corresponding with described source SQL database type; According to the described source of rule analysis of the reading SQL code that comprises in the described content that reads, extract key word and the corresponding grammer logic of described source SQL code;
Search the unit, be used for searching described translation logic according to described source SQL database type and purpose SQL database type, obtain corresponding key word and grammer logic in the corresponding purpose SQL database of the key word that obtains with described compiling and grammer logic;
Translate the unit, be used for according to other code except key word in the described key word that obtains of the grammer logical combination of described purpose SQL database and the described source SQL code, generate purpose SQL code.
7. device according to claim 6 is characterized in that, described acquiring unit comprises:
The source code receiving element is used for receiving the source SQL code by the application interface input;
The Source Type judging unit is used for judging SQL database type under the SQL code of described source according to the content of described source SQL code, as source SQL database type;
Purpose type receiving element is used for receiving the purpose SQL database type of selecting by application interface.
8. device according to claim 6 is characterized in that, also comprises:
Updating block is used for upgrading described translation logic when the new database SQL type of adding, increases key word and the key word of already present each database SQL of grammer logical and and the corresponding relation of grammer logic of described new database SQL.
CN 200910246314 2009-11-25 2009-11-25 Method and device for translating database language Active CN102073490B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN 200910246314 CN102073490B (en) 2009-11-25 2009-11-25 Method and device for translating database language
HK11107091.0A HK1153017A1 (en) 2009-11-25 2011-07-08 A method and device for translating database language

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200910246314 CN102073490B (en) 2009-11-25 2009-11-25 Method and device for translating database language

Publications (2)

Publication Number Publication Date
CN102073490A CN102073490A (en) 2011-05-25
CN102073490B true CN102073490B (en) 2013-09-11

Family

ID=44032039

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200910246314 Active CN102073490B (en) 2009-11-25 2009-11-25 Method and device for translating database language

Country Status (2)

Country Link
CN (1) CN102073490B (en)
HK (1) HK1153017A1 (en)

Families Citing this family (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102339317A (en) * 2011-10-20 2012-02-01 北京握奇数据系统有限公司 High-capacity database card and data communication method thereof
CN102750374A (en) * 2012-06-20 2012-10-24 深圳市远行科技有限公司 Data tracing and influence relationship analysis method based on database script
CN102902820B (en) * 2012-10-31 2015-09-09 华为技术有限公司 The recognition methods of type of database and device
CN104252511A (en) * 2013-11-05 2014-12-31 深圳市华傲数据技术有限公司 SQL (Structural Query Language) command compiling method and SQL command compiling device
CN104252510A (en) * 2013-11-05 2014-12-31 深圳市华傲数据技术有限公司 SQL (Structural Query Language) language translation method and SQL language translation device
CN103914572A (en) * 2014-04-29 2014-07-09 福建星网视易信息系统有限公司 Database construction system, device and method
CN104731597A (en) * 2015-03-30 2015-06-24 上海华力微电子有限公司 Method for applying SQL statements to engineering software compiling platform
CN106126540B (en) * 2016-06-15 2019-07-09 中国传媒大学 Data base access system and its access method
CN107391368B (en) * 2017-07-13 2021-02-09 中国航发控制系统研究所 Method for analyzing consistency of source code and target code in airborne software
CN110309171B (en) * 2018-02-26 2021-08-20 华为技术有限公司 Database query method, server and system
CN110399384B (en) * 2018-04-23 2023-12-15 阿里巴巴集团控股有限公司 UDF adaptation method, data processing method, device and storage medium
CN109062918A (en) * 2018-05-31 2018-12-21 阿里巴巴集团控股有限公司 A kind of method and device of SQL statement conversion
CN109408528B (en) * 2018-10-25 2022-07-15 北京信安世纪科技股份有限公司 Database script generation method and device, calculation device and storage medium
CN110008448B (en) * 2019-04-02 2023-10-17 中国工商银行股份有限公司 Method and device for automatically converting SQL code into Java code
CN110134404A (en) * 2019-04-12 2019-08-16 深圳壹账通智能科技有限公司 Code translation method, apparatus, computer equipment and storage medium
CN110990016B (en) * 2019-11-29 2023-08-29 浪潮商用机器有限公司 Command acquisition method, device, equipment and page of Linux operating system
CN111125218A (en) * 2019-12-13 2020-05-08 成都安恒信息技术有限公司 Database compatibility method based on protocol analysis and compatibility proxy device thereof
CN111061757B (en) * 2019-12-19 2023-03-31 用友网络科技股份有限公司 Language conversion method and device of database, electronic equipment and storage medium
CN112000690B (en) * 2020-08-19 2024-03-19 北京人大金仓信息技术股份有限公司 Method and device for analyzing structured operation statement
CN113391818A (en) * 2021-03-26 2021-09-14 广州海量数据库技术有限公司 Compiled file generation method and device
CN113127124A (en) * 2021-04-21 2021-07-16 平安付科技服务有限公司 Database language type switching method and device, computer equipment and storage medium
CN114047927B (en) * 2022-01-11 2022-04-29 山东捷瑞数字科技股份有限公司 Database code conversion method and system
CN115757339A (en) * 2022-11-16 2023-03-07 恒辉信达技术有限公司 Method for automatically converting Oracle script into Postgresql script

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5809505A (en) * 1996-06-14 1998-09-15 Lo; Thomas System and method for relational to object mapping
EP1388793A2 (en) * 2002-08-09 2004-02-11 Joint Technology Corporation Method for transforming SQL queries
CN101105814A (en) * 2007-09-11 2008-01-16 金蝶软件(中国)有限公司 Method and device for converting Script language to SQL language
CN101561817A (en) * 2009-06-02 2009-10-21 天津大学 Conversion algorithm from XQuery to SQL query language and method for querying relational data

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5809505A (en) * 1996-06-14 1998-09-15 Lo; Thomas System and method for relational to object mapping
EP1388793A2 (en) * 2002-08-09 2004-02-11 Joint Technology Corporation Method for transforming SQL queries
CN101105814A (en) * 2007-09-11 2008-01-16 金蝶软件(中国)有限公司 Method and device for converting Script language to SQL language
CN101561817A (en) * 2009-06-02 2009-10-21 天津大学 Conversion algorithm from XQuery to SQL query language and method for querying relational data

Also Published As

Publication number Publication date
CN102073490A (en) 2011-05-25
HK1153017A1 (en) 2012-03-16

Similar Documents

Publication Publication Date Title
CN102073490B (en) Method and device for translating database language
US8126901B2 (en) Method and apparatus for generating a dynamic web page
US8997070B2 (en) Extension mechanism for scripting language compiler
CN108491199B (en) Method and terminal for automatically generating interface
CN101233487B (en) Lambda expressions
US8244780B1 (en) Parameter oriented automated database command
CN101300577A (en) Partial xml validation
US20090030902A1 (en) Schematized data intelligent assistance for development environments
CN104133772A (en) Automatic test data generation method
CN102750152A (en) Method and device of application for generating a plurality of programming languages based on descriptive language
US8135716B2 (en) Systems and method for mapping large object data content in a database table to a work area
US20040019589A1 (en) Driver for mapping standard database queries and commands to markup language documents
CN115269629A (en) Data query method and system supporting multiple data sources
CN102460381A (en) Software extension analysis
KR101769848B1 (en) A data processing system using scripts by using commercial interpreter
US6592628B1 (en) Modular storage method and apparatus for use with software applications
CN111782195A (en) Query method based on adding annotation on request parameter and splicing into SQL
CN103809915A (en) Read-write method and device of magnetic disk files
CN113687827B (en) Data list generation method, device and equipment based on widget and storage medium
US20150324333A1 (en) Systems and methods for automatically generating hyperlinks
CN116756184B (en) Database instance processing method, device, equipment, storage medium and program product
CN114003317A (en) Inline implementation method and apparatus, electronic device, storage medium, and program product
CN115951888A (en) Method for positioning program source code position and computing equipment
CN115794858A (en) Query statement processing method, device, equipment and storage medium
CN113961192A (en) Code data processing method and device and electronic equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 1153017

Country of ref document: HK

C14 Grant of patent or utility model
GR01 Patent grant
REG Reference to a national code

Ref country code: HK

Ref legal event code: GR

Ref document number: 1153017

Country of ref document: HK