CN109446218A - SQL statement generation method, device and computer readable storage medium - Google Patents

SQL statement generation method, device and computer readable storage medium Download PDF

Info

Publication number
CN109446218A
CN109446218A CN201811114707.XA CN201811114707A CN109446218A CN 109446218 A CN109446218 A CN 109446218A CN 201811114707 A CN201811114707 A CN 201811114707A CN 109446218 A CN109446218 A CN 109446218A
Authority
CN
China
Prior art keywords
sql statement
client
code
sent
editing interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811114707.XA
Other languages
Chinese (zh)
Inventor
陈佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China 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 Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201811114707.XA priority Critical patent/CN109446218A/en
Publication of CN109446218A publication Critical patent/CN109446218A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a kind of SQL statement generation methods, this method comprises: generating SQL statement editing interface when receiving the structured query language SQL statement creation instruction of client transmission and being sent to client and show;The component selection instruction that client is sent is received, determines corresponding atomic sentence, obtain the code with the atomic sentence and is sent to client to show in code region, determines user based on the statement parameter that SQL statement editing interface is that atomic sentence is arranged;The code that the code for the atomic sentence for being provided with statement parameter is combined, and combined in the code region simultaneous display of client in buffer zone;Above-mentioned steps are repeated, instruction are completed based on the editor that SQL statement editing interface is sent until receiving client, according to the code building SQL statement combined in buffer zone.The present invention also proposes a kind of SQL statement generating means and a kind of computer readable storage medium.What the present invention improved SQL statement writes efficiency.

Description

SQL statement generation method, device and computer readable storage medium
Technical field
The present invention relates to field of computer technology more particularly to a kind of SQL statement generation methods, device and computer-readable Storage medium.
Background technique
In existing some business items management, frequently refer to the processing to database data, such as access data with And query, update, and manage database etc., these data process methods are required through SQL (Structured Query Language, structured query language) sentence is realized, and the realization of data process method is related to domain knowledge mostly, Developer is needed to understand business demand, when there is new business demand, it is necessary to rewrite corresponding SQL statement to realize Corresponding logic not only needs special developer to write a large amount of SQL statement manually, can also face compiling report an error show As lead to SQL statement writes inefficiency.
Summary of the invention
The present invention provides a kind of SQL statement generation method, device and computer readable storage medium, main purpose and is That improves SQL statement writes efficiency.
To achieve the above object, the present invention also provides a kind of SQL statement generation methods, this method comprises:
When receiving the structured query language SQL statement creation instruction of client transmission, SQL statement editor circle is generated Face is simultaneously sent to the client and shows, wherein the SQL statement editing interface includes code region and editing component area;
The component selection instruction that client is triggered based on the SQL statement editing interface is received, determines the component selection Corresponding atomic sentence is instructed, the code with the atomic sentence is obtained from description components library;
The code is sent to the client to show in the code region, determines that user is based on the SQL language Sentence editing interface is the statement parameter of atomic sentence setting;
The code for the atomic sentence for being provided with statement parameter is combined in buffer zone, and in the client The code that code region simultaneous display combines;
Above-mentioned steps are repeated, until receiving the volume that the client is sent based on the SQL statement editing interface It collects and completes instruction, according to the code building SQL statement combined in buffer zone.
Optionally, described when receiving the SQL statement creation instruction of client transmission, generate SQL statement editing interface And the step of being sent to client display, includes:
When receiving the SQL statement creation instruction of client transmission, determine that the SQL statement creation instructs corresponding number According to library type;
According to the mapping relations of pre-set type of database and SQL statement editing interface, generate and the database The SQL statement editing interface of type matching is simultaneously sent to the client and shows.
It optionally, further include SQL statement stencil-chosen region on the SQL statement editing interface, it is described to receive visitor Family end send SQL statement create instruction when, generate SQL statement editing interface and be sent to the client display the step of it Afterwards, the method also includes:
It is instructed, is obtained based on the stencil-chosen that SQL statement stencil-chosen region is sent when receiving the client The code of corresponding default SQL statement template is instructed with the stencil-chosen, and is based on the code building parameter setting interface It is sent to the client, wherein critical field to be entered is replaced with placeholder in the code of the default SQL statement template Generation;
User's critical field that set interface inputs based on the parameter is received, is replaced using the critical field described pre- If corresponding placeholder in SQL statement template, SQL statement is generated.
Optionally, the default SQL statement template includes stsndard SQL sentence template and storing process template.
Optionally, described according to after the step of the code building SQL statement combined in buffer zone, the method is also wrapped It includes:
The SQL statement of generation is detected according to preset multiple test orders, judges that the logic of the SQL statement is It is no correct;
If logically true, the SQL statement is stored;
If logic error, it is determined that the atomic sentence of logic error occurs, and is sent based on the atomic sentence to client Prompt information, so that user modifies to SQL statement according to prompt information.
In addition, to achieve the above object, the present invention also provides a kind of SQL statement generating means, which includes memory And processor, the SQL statement that be stored in the memory to run on the processor generate program, the SQL statement It generates when program is executed by the processor and realizes following steps:
When receiving the structured query language SQL statement creation instruction of client transmission, SQL statement editor circle is generated Face is simultaneously sent to the client and shows, wherein the SQL statement editing interface includes code region and editing component area;
The component selection instruction that client is triggered based on the SQL statement editing interface is received, determines the component selection Corresponding atomic sentence is instructed, the code with the atomic sentence is obtained from description components library;
The code is sent to the client to show in the code region, determines that user is based on the SQL language Sentence editing interface is the statement parameter of atomic sentence setting;
The code for the atomic sentence for being provided with statement parameter is combined in buffer zone, and in the client The code that code region simultaneous display combines;
Above-mentioned steps are repeated, until receiving the volume that the client is sent based on the SQL statement editing interface It collects and completes instruction, according to the code building SQL statement combined in buffer zone.
Optionally, described when receiving the SQL statement creation instruction of client transmission, generate SQL statement editing interface And the step of being sent to client display, includes:
When receiving the SQL statement creation instruction of client transmission, determine that the SQL statement creation instructs corresponding number According to library type;
According to the mapping relations of pre-set type of database and SQL statement editing interface, generate and the database The SQL statement editing interface of type matching is simultaneously sent to the client and shows.
It optionally, further include SQL statement stencil-chosen region on the SQL statement editing interface, the SQL statement generates Program can be also executed by processor, when receiving the SQL statement creation instruction of client transmission, to generate SQL language described Sentence editing interface is simultaneously sent to after the step of client is shown, also realization following steps:
It is instructed, is obtained based on the stencil-chosen that SQL statement stencil-chosen region is sent when receiving the client The code of corresponding default SQL statement template is instructed with the stencil-chosen, and is based on the code building parameter setting interface It is sent to the client, wherein critical field to be entered is replaced with placeholder in the code of the default SQL statement template Generation;
User's critical field that set interface inputs based on the parameter is received, is replaced using the critical field described pre- If corresponding placeholder in SQL statement template, SQL statement is generated.
Optionally, the SQL statement generates program and can also be executed by processor, to combine described according in buffer zone Code building SQL statement the step of after, also realization following steps:
The SQL statement of generation is detected according to preset multiple test orders, judges that the logic of the SQL statement is It is no correct;
If logically true, the SQL statement is stored;
If logic error, it is determined that the atomic sentence of logic error occurs, and is sent based on the atomic sentence to client Prompt information, so that user modifies to SQL statement according to prompt information.
In addition, to achieve the above object, it is described computer-readable the present invention also provides a kind of computer readable storage medium It is stored with SQL statement on storage medium and generates program, the SQL statement generates program and can be held by one or more processor Row, the step of to realize SQL statement generation method as described above.
SQL statement generation method, device and computer readable storage medium proposed by the present invention are sent out when receiving client When the structured query language SQL statement creation instruction sent, generates SQL statement editing interface and is sent to client and shows, In, SQL statement editing interface includes code region and editing component area;Client is received to trigger based on SQL statement editing interface Component selection instruction, determine the corresponding atomic sentence of component selection instruction, from description components library obtain with the atomic sentence Code;Code is sent to client to show in code region, determining that user is based on SQL statement editing interface is atom language The statement parameter of sentence setting;The code for the atomic sentence for being provided with statement parameter is combined in buffer zone, and in visitor The code that the code region simultaneous display at family end combines;Above-mentioned steps are repeated, until receiving client is based on SQL The editor that statement editing interface is sent completes instruction, according to the code building SQL statement combined in buffer zone.Through the invention Scheme, in the case where explicit data process demand, can be selected on SQL statement editing interface need atomic sentence pair Simultaneously statement parameter is arranged in the control answered, can automatically and accurately generate SQL statement, improve SQL statement writes efficiency.
Detailed description of the invention
Fig. 1 is the flow diagram for the SQL statement generation method that one embodiment of the invention provides;
Fig. 2 is the schematic diagram of internal structure for the SQL statement generating means that one embodiment of the invention provides;
SQL statement generates the module signal of program in the SQL statement generating means that Fig. 3 provides for one embodiment of the invention Figure.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
The present invention provides a kind of SQL statement generation method.It is the SQL language that one embodiment of the invention provides shown in referring to Fig.1 The flow diagram of sentence generating method.This method can be executed by a device, which can be by software and/or hardware reality It is existing.
In the present embodiment, SQL statement generation method includes:
Step S10 generates SQL language when receiving the structured query language SQL statement creation instruction of client transmission Sentence editing interface is simultaneously sent to the client and shows, wherein the SQL statement editing interface includes code region and editor's group Part area.
In the embodiment of the present invention, user can perhaps web interface writes SQL statement client or clear by client It lookes between device and server and establishes telecommunication connection.When user needs to create data process method, that is, need to create SQL statement When, SQL statement creation instruction is sent by user end to server, server generates SQL statement and compile when receiving the instruction Editing interface is sent to client displaying, includes code region and editing component area, code region on the SQL statement editing interface SQL statement code is shown for synchronous, there is the control of various pre-set atomic sentences in editing component area.
Specifically, SQL is the grammer for executing inquiry, can be used for the grammer of update, insertion and deletion record.Its In, SQL mainly includes DML and DDL.DML (Data Manipulation Language, data manipulation language) is responsible for logarithm According to the instruction set of library object operation data access work, instructed with tri- kinds of INSERT, UPDATE, DELETE as core, respectively generation Table insertion is updated and is deleted.The primary commands of DDL (Data Definition Language, mode data definitional language) have CREATE (creation), ALTER (modification), DROP (deletion) etc., DDL mainly be used in definition or change table structure, data type, In the work such as link and constraint between table, the use when building table mostly.
Step S20, receives the component selection instruction that trigger based on the SQL statement editing interface of client, described in determination The corresponding atomic sentence of component selection instruction obtains the code with the atomic sentence from description components library.
The code is sent to the client to show in the code region, determines that user is based on institute by step S30 State the statement parameter that SQL statement editing interface is atomic sentence setting.
Step S40 is combined the code for the atomic sentence for being provided with statement parameter in buffer zone, and described The code that the code region simultaneous display of client combines.
Atomic sentence is pre-created to store into the Component Gallery of server, these atomic sentences are set in editing component area Control, atomic sentence can be in such as logic IF, logic casewhen, aggregation function and various calculating function SQL statements Common grammer.User may be implemented to generate variable, defines the SQL languages such as vernier by clicking the control of preset atomic sentence Sentence.User selects corresponding atomic sentence by clicking the control trigger assembly selection instruction in editing component area, and server is connecing When receiving component selection instruction, determines the corresponding atomic sentence of the instruction, the generation of corresponding atomic sentence is obtained from Component Gallery It piles up in caching, user can select multiple atomic sentences in this way and be sent to service for its setting statement parameter Device, the statement parameter of atomic sentence and setting that server is selected according to user, which in the buffer splices and combines these codes, to be become One section of complete SQL statement, meanwhile, when user selects atomic sentence and setting statement parameter, by the code of atomic sentence Code region of the synchronous display to client.
Step S50, repeats above-mentioned steps, until receiving the client is based on the SQL statement editing interface The editor of transmission completes instruction, according to the code building SQL statement combined in buffer zone.
User can repeat as procedure described above, until completing writing for whole SQL statements.
It further, further include SQL statement stencil-chosen region on the SQL statement editing interface, user can pass through The regional choice presets SQL statement template, wherein default SQL statement template includes stsndard SQL sentence template and storing process mould Plate, after step slo, this method further include following steps:
It is instructed when receiving client based on the stencil-chosen that SQL statement stencil-chosen region is sent, acquisition and institute The code that stencil-chosen instructs corresponding default SQL statement template is stated, and is sent based on the code building parameter setting interface To the client, wherein critical field to be entered is substituted with placeholder in the code of the default SQL statement template;
User's critical field that set interface inputs based on the parameter is received, is replaced using the critical field described pre- If corresponding placeholder in SQL statement template, SQL statement is generated.
For example, user will inquire data from tables of data A, then need to write data query SQL statement.It can choose at this time SQL statement template is preset, the critical fielies such as query object and data table name in the template are substituted using placeholder, and It is provided with the input frame of query object and data table name in parameter setting interface, field that user's input to be inquired and as looking into The title for asking the tables of data of object after server receives these data, is accordingly replaced using the above-mentioned field that user inputs The placeholder fallen in default SQL statement template generates SQL statement.In addition, system can also be docked with target database, tables of data The input frame of title the modes such as can provide drop-down, choose or click and selecting data table name in the database of docking for user Claim.It is understood that one or more default SQL statement when writing a data process method, can be used in user Template is combined.Alternatively, user will write a storing process, the storing process mould write in advance can be directly acquired Plate, user produce an executable storing process by specifying the title of storing process and providing parameter.
Further, since for different databases, such as Oracle, MSSQL, MySQL etc., they are in SQL syntax On can have subtle difference, built-in function also can be slightly different.Therefore, this programme is to that can support different types of data The SQL statement in library is write, and the difference in view of database dialect is needed.Therefore when atomic sentence library is pre-created, need to be directed to Each database creates the atomic sentence for meeting its dialect, while presetting and the matched SQL statement template of its dialect.
Therefore, step S10 may include following refinement step in some embodiments:
When receiving the SQL statement creation instruction of client transmission, determine that the SQL statement creation instructs corresponding number According to library type;
According to the mapping relations of pre-set type of database and SQL statement editing interface, generate and the database The SQL statement editing interface of type matching is simultaneously sent to the client and shows, wherein the SQL statement editing interface includes Code region and editing component area.
Further, user is when writing sentence using default SQL statement template or atomic sentence, it is also possible to compile The problem of mistake is translated, and hence it is also possible to which the sentence further completed to compiling is tested.Test order is preset, this The logic detection to the SQL statement write may be implemented in a little test orders, such as detects the beginning of query statement either with or without rope Draw, union connection when data volume, the condition of where is either with or without unique designation etc..Specifically, in other embodiments, according to After the code building SQL statement combined in buffer zone, this method further includes following steps:
The SQL statement of generation is detected according to preset multiple test orders, judges that the logic of the SQL statement is It is no correct;If logically true, the SQL statement is stored;If logic error, it is determined that the atomic sentence of logic error occurs, And prompt information is sent to client based on the atomic sentence, so that user modifies to SQL statement according to prompt information.
The SQL statement generation method that the present embodiment proposes, when the structured query language SQL language for receiving client transmission When sentence creation instruction, generates SQL statement editing interface and be sent to client and show, wherein SQL statement editing interface includes generation Code region and editing component area;The component selection instruction that client is triggered based on SQL statement editing interface is received, determines that component selects The corresponding atomic sentence of instruction is selected, the code with the atomic sentence is obtained from description components library;Code is sent to client To show in code region, determine user based on the statement parameter that SQL statement editing interface is that atomic sentence is arranged;In buffer area The code for the atomic sentence for being provided with statement parameter is combined in domain, and is combined in the code region simultaneous display of client Obtained code;Above-mentioned steps are repeated, are completed until receiving client based on the editor that SQL statement editing interface is sent Instruction, according to the code building SQL statement combined in buffer zone.Scheme through the invention, in explicit data process demand In the case where, the corresponding control of atomic sentence needed can be selected on SQL statement editing interface and statement parameter is set, i.e., SQL statement can be automatically and accurately generated, improve SQL statement writes efficiency.
The present invention also provides a kind of SQL statement generating means.It is the SQL that one embodiment of the invention provides referring to shown in Fig. 2 The schematic diagram of internal structure of sentence generating means.
In the present embodiment, SQL statement generating means 1 can be PC (Personal Computer, PC), It can be the terminal devices such as smart phone, tablet computer, portable computer.The SQL statement generating means 1 include at least memory 11, processor 12, network interface 13 and communication bus.
Wherein, memory 11 include at least a type of readable storage medium storing program for executing, the readable storage medium storing program for executing include flash memory, Hard disk, multimedia card, card-type memory (for example, SD or DX memory etc.), magnetic storage, disk, CD etc..Memory 11 It can be the internal storage unit of SQL statement generating means 1 in some embodiments, such as the SQL statement generating means 1 is hard Disk.Memory 11 is also possible to the External memory equipment of SQL statement generating means 1, such as SQL statement in further embodiments The plug-in type hard disk being equipped in generating means 1, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..Further, memory 11 can also both include that SQL statement generates dress The internal storage unit for setting 1 also includes External memory equipment.Memory 11 can be not only used for storage and be installed on SQL statement generation The application software and Various types of data of device 1, such as SQL statement generate the code etc. of program 01, can be also used for temporarily storing The data that has exported or will export.
Processor 12 can be in some embodiments a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor or other data processing chips, the program for being stored in run memory 11 Code or processing data, such as execute SQL statement and generate program 01 etc..
Network interface 13 optionally may include standard wireline interface and wireless interface (such as WI-FI interface), be commonly used in Communication connection is established between the device 1 and other electronic equipments.
Communication bus is for realizing the connection communication between these components.
Optionally, which can also include user interface, and user interface may include display (Display), input Unit such as keyboard (Keyboard), optional user interface can also include standard wireline interface and wireless interface.It is optional Ground, in some embodiments, display can be light-emitting diode display, liquid crystal display, touch-control liquid crystal display and OLED (Organic Light-Emitting Diode, Organic Light Emitting Diode) touches device etc..Wherein, display can also be appropriate Referred to as display screen or display unit, for being shown in the information handled in SQL statement generating means 1 and for showing visualization User interface.
Fig. 2 illustrates only the SQL statement generating means 1 that program 01 is generated with component 11-13 and SQL statement, ability Field technique personnel may include it is understood that structure shown in fig. 1 does not constitute the restriction to SQL statement generating means 1 Certain components or different component layouts are perhaps combined than illustrating less perhaps more components.
In 1 embodiment of device shown in Fig. 2, it is stored with SQL statement in memory 11 and generates program 01;Processor 12 is held The SQL statement stored in line storage 11 realizes following steps when generating program 01:
When receiving the structured query language SQL statement creation instruction of client transmission, SQL statement editor circle is generated Face is simultaneously sent to the client and shows, wherein the SQL statement editing interface includes code region and editing component area.
The component selection instruction that client is triggered based on the SQL statement editing interface is received, determines the component selection Corresponding atomic sentence is instructed, the code with the atomic sentence is obtained from description components library.
The code is sent to the client to show in the code region, determines that user is based on the SQL language Sentence editing interface is the statement parameter of atomic sentence setting.
The code for the atomic sentence for being provided with statement parameter is combined in buffer zone, and in the client The code that code region simultaneous display combines.
Above-mentioned steps are repeated, until receiving the volume that the client is sent based on the SQL statement editing interface It collects and completes instruction, according to the code building SQL statement combined in buffer zone.
In the embodiment of the present invention, user can perhaps web interface writes SQL statement client or clear by client It lookes between device and server and establishes telecommunication connection.When user needs to create data process method, that is, need to create SQL statement When, SQL statement creation instruction is sent by user end to server, server generates SQL statement and compile when receiving the instruction Editing interface is sent to client displaying, includes code region and editing component area, code region on the SQL statement editing interface SQL statement code is shown for synchronous, there is the control of various pre-set atomic sentences in editing component area.
Specifically, SQL is the grammer for executing inquiry, can be used for the grammer of update, insertion and deletion record.Its In, SQL mainly includes DML and DDL.DML (Data Manipulation Language, data manipulation language) is responsible for logarithm According to the instruction set of library object operation data access work, instructed with tri- kinds of INSERT, UPDATE, DELETE as core, respectively generation Table insertion is updated and is deleted.The primary commands of DDL (Data Definition Language, mode data definitional language) have CREATE (creation), ALTER (modification), DROP (deletion) etc., DDL mainly be used in definition or change table structure, data type, In the work such as link and constraint between table, the use when building table mostly.
Atomic sentence is pre-created to store into the Component Gallery of server, these atomic sentences are set in editing component area Control, atomic sentence can be in such as logic IF, logic casewhen, aggregation function and various calculating function SQL statements Common grammer.User may be implemented to generate variable, defines the SQL languages such as vernier by clicking the control of preset atomic sentence Sentence.User selects corresponding atomic sentence by clicking the control trigger assembly selection instruction in editing component area, and server is connecing When receiving component selection instruction, determines the corresponding atomic sentence of the instruction, the generation of corresponding atomic sentence is obtained from Component Gallery It piles up in caching, user can select multiple atomic sentences in this way and be sent to service for its setting statement parameter Device, the statement parameter of atomic sentence and setting that server is selected according to user, which in the buffer splices and combines these codes, to be become One section of complete SQL statement, meanwhile, when user selects atomic sentence and setting statement parameter, by the code of atomic sentence Code region of the synchronous display to client.User can repeat as procedure described above, until completing the volume of whole SQL statements It writes.
It further, further include SQL statement stencil-chosen region on the SQL statement editing interface, user can pass through The regional choice presets SQL statement template, wherein default SQL statement template includes stsndard SQL sentence template and storing process mould Plate, SQL statement generate program 01 and can also be executed by processor 12, to work as the SQL statement wound for receiving client and sending described It when building instruction, generates SQL statement editing interface and is sent to after the step of client is shown, also realization following steps:
It is instructed when receiving client based on the stencil-chosen that SQL statement stencil-chosen region is sent, acquisition and institute The code that stencil-chosen instructs corresponding default SQL statement template is stated, and is sent based on the code building parameter setting interface To the client, wherein critical field to be entered is substituted with placeholder in the code of the default SQL statement template;
User's critical field that set interface inputs based on the parameter is received, is replaced using the critical field described pre- If corresponding placeholder in SQL statement template, SQL statement is generated.
For example, user will inquire data from tables of data A, then need to write data query SQL statement.It can choose at this time SQL statement template is preset, the critical fielies such as query object and data table name in the template are substituted using placeholder, and It is provided with the input frame of query object and data table name in parameter setting interface, field that user's input to be inquired and as looking into The title for asking the tables of data of object after server receives these data, is accordingly replaced using the above-mentioned field that user inputs The placeholder fallen in default SQL statement template generates SQL statement.In addition, system can also be docked with target database, tables of data The input frame of title the modes such as can provide drop-down, choose or click and selecting data table name in the database of docking for user Claim.It is understood that one or more default SQL statement when writing a data process method, can be used in user Template is combined.Alternatively, user will write a storing process, the storing process mould write in advance can be directly acquired Plate, user produce an executable storing process by specifying the title of storing process and providing parameter.
Further, since for different databases, such as Oracle, MSSQL, MySQL etc., they are in SQL syntax On can have subtle difference, built-in function also can be slightly different.Therefore, this programme is to that can support different types of data The SQL statement in library is write, and the difference in view of database dialect is needed.Therefore when atomic sentence library is pre-created, need to be directed to Each database creates the atomic sentence for meeting its dialect, while presetting and the matched SQL statement template of its dialect.
Therefore, in some embodiments, when receiving the SQL statement creation instruction of client transmission, SQL statement is generated Editing interface and be sent to the client display the step of may include following refinement step:
When receiving the SQL statement creation instruction of client transmission, determine that the SQL statement creation instructs corresponding number According to library type;
According to the mapping relations of pre-set type of database and SQL statement editing interface, generate and the database The SQL statement editing interface of type matching is simultaneously sent to the client and shows, wherein the SQL statement editing interface includes Code region and editing component area.
Further, user is when writing sentence using default SQL statement template or atomic sentence, it is also possible to compile The problem of mistake is translated, and hence it is also possible to which the sentence further completed to compiling is tested.Test order is preset, this The logic detection to the SQL statement write may be implemented in a little test orders, such as detects the beginning of query statement either with or without rope Draw, union connection when data volume, the condition of where is either with or without unique designation etc..Specifically, in other embodiments, SQL Sentence generates program 01 and can also be executed by processor 12, to instruct described when the SQL statement for receiving client transmission creates When, it generates SQL statement editing interface and is sent to after the client show, also realize following steps:
The SQL statement of generation is detected according to preset multiple test orders, judges that the logic of the SQL statement is It is no correct;If logically true, the SQL statement is stored;If logic error, it is determined that the atomic sentence of logic error occurs, And prompt information is sent to client based on the atomic sentence, so that user modifies to SQL statement according to prompt information.
The SQL statement generating means that the present embodiment proposes, when the structured query language SQL language for receiving client transmission When sentence creation instruction, generates SQL statement editing interface and be sent to client and show, wherein SQL statement editing interface includes generation Code region and editing component area;The component selection instruction that client is triggered based on SQL statement editing interface is received, determines that component selects The corresponding atomic sentence of instruction is selected, the code with the atomic sentence is obtained from description components library;Code is sent to client To show in code region, determine user based on the statement parameter that SQL statement editing interface is that atomic sentence is arranged;In buffer area The code for the atomic sentence for being provided with statement parameter is combined in domain, and is combined in the code region simultaneous display of client Obtained code;Above-mentioned steps are repeated, are completed until receiving client based on the editor that SQL statement editing interface is sent Instruction, according to the code building SQL statement combined in buffer zone.Scheme through the invention, in explicit data process demand In the case where, the corresponding control of atomic sentence needed can be selected on SQL statement editing interface and statement parameter is set, i.e., SQL statement can be automatically and accurately generated, improve SQL statement writes efficiency.
Optionally, in other examples, SQL statement, which generates program, can also be divided into one or more mould Block, one or more module are stored in memory 11, and (the present embodiment is processor by one or more processors 12) performed to complete the present invention, the so-called module of the present invention is the series of computation machine program for referring to complete specific function Instruction segment generates implementation procedure of the program in SQL statement generating means for describing SQL statement.
For example, referring to shown in Fig. 3, program is generated for the SQL statement in one embodiment of SQL statement generating means of the present invention Program module schematic diagram, in the embodiment, SQL statement generates that program 01 can be divided into data transmission blocks 10, code obtains Modulus block 20, parameter determination module 30 and code combination module 40, illustratively:
Data transmission blocks 10 are used for: when the structured query language SQL statement creation instruction for receiving client transmission When, it generates SQL statement editing interface and is sent to the client and shows, wherein the SQL statement editing interface includes code Region and editing component area;
Code obtaining module 20 is used for: being received client and is referred to based on the component selection that the SQL statement editing interface triggers It enables, determines the corresponding atomic sentence of the component selection instruction, the code with the atomic sentence is obtained from description components library;
The data transmission blocks 10 are also used to: the code is sent to the client in the code region exhibition Show;
Parameter determination module 30 is used for: determining that user is based on the SQL statement editing interface as atomic sentence setting Statement parameter;
Code combination module 40 is used for: carrying out group to the code for the atomic sentence for being provided with statement parameter in buffer zone It closes, and the code combined in the code region simultaneous display of the client;
Above-mentioned module repeats above-mentioned steps, until receiving the client is based on the SQL statement editing interface The editor of transmission completes instruction, and code combination module 40 is according to the code building SQL statement combined in buffer zone.
The journeys such as above-mentioned data transmission blocks 10, Code obtaining module 20, parameter determination module 30 and code combination module 40 Sequence module is performed realized functions or operations step and is substantially the same with above-described embodiment, and details are not described herein.
In addition, the embodiment of the present invention also proposes a kind of computer readable storage medium, the computer readable storage medium On be stored with SQL statement and generate program, the SQL statement generates program and can be executed by one or more processors, to realize such as Lower operation:
When receiving the structured query language SQL statement creation instruction of client transmission, SQL statement editor circle is generated Face is simultaneously sent to the client and shows, wherein the SQL statement editing interface includes code region and editing component area;
The component selection instruction that client is triggered based on the SQL statement editing interface is received, determines the component selection Corresponding atomic sentence is instructed, the code with the atomic sentence is obtained from description components library;
The code is sent to the client to show in the code region, determines that user is based on the SQL language Sentence editing interface is the statement parameter of atomic sentence setting;
The code for the atomic sentence for being provided with statement parameter is combined in buffer zone, and in the client The code that code region simultaneous display combines;
Above-mentioned steps are repeated, until receiving the volume that the client is sent based on the SQL statement editing interface It collects and completes instruction, according to the code building SQL statement combined in buffer zone.
Computer readable storage medium specific embodiment of the present invention is respectively implemented with above-mentioned SQL statement generating means and method Example is essentially identical, does not make tired state herein.
It should be noted that the serial number of the above embodiments of the invention is only for description, do not represent the advantages or disadvantages of the embodiments.And The terms "include", "comprise" herein or any other variant thereof is intended to cover non-exclusive inclusion, so that packet Process, device, article or the method for including a series of elements not only include those elements, but also including being not explicitly listed Other element, or further include for this process, device, article or the intrinsic element of method.Do not limiting more In the case where, the element that is limited by sentence "including a ...", it is not excluded that including process, device, the article of the element Or there is also other identical elements in method.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in one as described above In storage medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that terminal device (it can be mobile phone, Computer, server or network equipment etc.) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills Art field, is included within the scope of the present invention.

Claims (10)

1. a kind of SQL statement generation method, which is characterized in that the described method includes:
When receiving the structured query language SQL statement creation instruction of client transmission, SQL statement editing interface is generated simultaneously It is sent to the client to show, wherein the SQL statement editing interface includes code region and editing component area;
The component selection instruction that client is triggered based on the SQL statement editing interface is received, determines the component selection instruction Corresponding atomic sentence obtains the code with the atomic sentence from description components library;
The code is sent to the client to show in the code region, determines that user is compiled based on the SQL statement Editing interface is the statement parameter of atomic sentence setting;
The code for the atomic sentence for being provided with statement parameter is combined in buffer zone, and in the code of the client The code that region simultaneous display combines;
Above-mentioned steps are repeated, until it is complete to receive the editor that the client is sent based on the SQL statement editing interface At instruction, according to the code building SQL statement combined in buffer zone.
2. SQL statement generation method as described in claim 1, which is characterized in that described as the SQL for receiving client transmission When sentence creation instruction, generates SQL statement editing interface and include: the step of being sent to client display
When receiving the SQL statement creation instruction of client transmission, determine that the SQL statement creation instructs corresponding database Type;
According to the mapping relations of pre-set type of database and SQL statement editing interface, generate and the type of database Matched SQL statement editing interface is simultaneously sent to the client and shows.
3. SQL statement generation method as described in claim 1, which is characterized in that further include on the SQL statement editing interface SQL statement stencil-chosen region, it is described when receiving the SQL statement creation instruction of client transmission, generate SQL statement editor Interface is simultaneously sent to after the step of client is shown, the method also includes:
It is instructed when receiving the client based on the stencil-chosen that SQL statement stencil-chosen region is sent, acquisition and institute The code that stencil-chosen instructs corresponding default SQL statement template is stated, and is sent based on the code building parameter setting interface To the client, wherein critical field to be entered is substituted with placeholder in the code of the default SQL statement template;
User's critical field that set interface inputs based on the parameter is received, is replaced using the critical field described default Corresponding placeholder in SQL statement template generates SQL statement.
4. SQL statement generation method as claimed in claim 3, which is characterized in that the default SQL statement template includes standard SQL statement template and storing process template.
5. SQL statement generation method according to any one of claims 1 to 4, which is characterized in that described according to buffer zone After the step of middle combined code building SQL statement, the method also includes:
The SQL statement of generation is detected according to preset multiple test orders, whether just to judge the logic of the SQL statement Really;
If logically true, the SQL statement is stored;
If logic error, it is determined that the atomic sentence of logic error occurs, and is sent and is prompted to client based on the atomic sentence Information, so that user modifies to SQL statement according to prompt information.
6. a kind of SQL statement generating means, which is characterized in that described device includes memory and processor, on the memory The SQL statement that be stored with to run on the processor generates program, and the SQL statement generates program and held by the processor Following steps are realized when row:
When receiving the structured query language SQL statement creation instruction of client transmission, SQL statement editing interface is generated simultaneously It is sent to the client to show, wherein the SQL statement editing interface includes code region and editing component area;
The component selection instruction that client is triggered based on the SQL statement editing interface is received, determines the component selection instruction Corresponding atomic sentence obtains the code with the atomic sentence from description components library;
The code is sent to the client to show in the code region, determines that user is compiled based on the SQL statement Editing interface is the statement parameter of atomic sentence setting;
The code for the atomic sentence for being provided with statement parameter is combined in buffer zone, and in the code of the client The code that region simultaneous display combines;
Above-mentioned steps are repeated, until it is complete to receive the editor that the client is sent based on the SQL statement editing interface At instruction, according to the code building SQL statement combined in buffer zone.
7. SQL statement generating means as claimed in claim 6, which is characterized in that described as the SQL for receiving client transmission When sentence creation instruction, generates SQL statement editing interface and include: the step of being sent to client display
When receiving the SQL statement creation instruction of client transmission, determine that the SQL statement creation instructs corresponding database Type;
According to the mapping relations of pre-set type of database and SQL statement editing interface, generate and the type of database Matched SQL statement editing interface is simultaneously sent to the client and shows.
8. SQL statement generating means as claimed in claim 6, which is characterized in that further include on the SQL statement editing interface SQL statement stencil-chosen region, the SQL statement generate program and can also be executed by processor, ought receive client described End send SQL statement create instruction when, generate SQL statement editing interface and be sent to the client display the step of it Afterwards, following steps are also realized:
It is instructed when receiving the client based on the stencil-chosen that SQL statement stencil-chosen region is sent, acquisition and institute The code that stencil-chosen instructs corresponding default SQL statement template is stated, and is sent based on the code building parameter setting interface To the client, wherein critical field to be entered is substituted with placeholder in the code of the default SQL statement template;
User's critical field that set interface inputs based on the parameter is received, is replaced using the critical field described default Corresponding placeholder in SQL statement template generates SQL statement.
9. the SQL statement generating means as described in any one of claim 6 to 8, which is characterized in that the SQL statement generates Program can be also executed by processor, with it is described according to the code building SQL statement combined in buffer zone the step of after, also Realize following steps:
The SQL statement of generation is detected according to preset multiple test orders, whether just to judge the logic of the SQL statement Really;
If logically true, the SQL statement is stored;
If logic error, it is determined that the atomic sentence of logic error occurs, and is sent and is prompted to client based on the atomic sentence Information, so that user modifies to SQL statement according to prompt information.
10. a kind of computer readable storage medium, which is characterized in that be stored with SQL language on the computer readable storage medium Sentence generates program, and the SQL statement generates program and can be executed by one or more processor, to realize such as claim 1 to 5 Any one of described in SQL statement generation method the step of.
CN201811114707.XA 2018-09-25 2018-09-25 SQL statement generation method, device and computer readable storage medium Pending CN109446218A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811114707.XA CN109446218A (en) 2018-09-25 2018-09-25 SQL statement generation method, device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811114707.XA CN109446218A (en) 2018-09-25 2018-09-25 SQL statement generation method, device and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN109446218A true CN109446218A (en) 2019-03-08

Family

ID=65530727

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811114707.XA Pending CN109446218A (en) 2018-09-25 2018-09-25 SQL statement generation method, device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN109446218A (en)

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109947790A (en) * 2019-03-19 2019-06-28 优刻得科技股份有限公司 The method, apparatus and non-volatile memory medium of cloud resource management
CN110008232A (en) * 2019-04-11 2019-07-12 北京启迪区块链科技发展有限公司 Generation method, device, server and the medium of structured query sentence
CN110059721A (en) * 2019-03-16 2019-07-26 平安城市建设科技(深圳)有限公司 Floor plan area recognizing method, device, equipment and computer readable storage medium
CN110222033A (en) * 2019-05-28 2019-09-10 长沙市海图科技有限公司 Simulation spatial service method, apparatus, equipment and storage medium based on SQL configuration
CN110377429A (en) * 2019-07-24 2019-10-25 深圳乐信软件技术有限公司 A kind of control method, device, server and storage medium that real-time task calculates
CN110413675A (en) * 2019-07-24 2019-11-05 深圳乐信软件技术有限公司 A kind of control method, device, server and storage medium that real-time task calculates
CN110781205A (en) * 2019-09-12 2020-02-11 成都四方伟业软件股份有限公司 JDBC-based database direct-checking method, device and system
CN111292721A (en) * 2020-02-20 2020-06-16 深圳壹账通智能科技有限公司 Code compiling method and device and computer equipment
CN111530082A (en) * 2020-05-25 2020-08-14 网易(杭州)网络有限公司 Editing method and device for judging sentences
CN111797637A (en) * 2020-07-21 2020-10-20 苏州思必驰信息科技有限公司 Interactive labeling method and device
CN112650766A (en) * 2019-10-10 2021-04-13 腾讯科技(深圳)有限公司 Database data operation method, system and server
CN112765158A (en) * 2020-12-30 2021-05-07 中国人寿保险股份有限公司上海数据中心 Data modification method and device of database and storage medium
CN112799659A (en) * 2021-01-12 2021-05-14 杨飞 Method, device and terminal for automatically generating data interface without programming
CN113051262A (en) * 2021-04-30 2021-06-29 中国银行股份有限公司 Data quality inspection method, device, equipment and storage medium
CN113377615A (en) * 2021-06-08 2021-09-10 上海天旦网络科技发展有限公司 Bypass database monitoring method and system
WO2021174756A1 (en) * 2020-03-04 2021-09-10 深圳壹账通智能科技有限公司 Application system deployment method and apparatus, and computer device and storage medium
CN113434133A (en) * 2021-08-27 2021-09-24 深圳市信润富联数字科技有限公司 Application building method, device, equipment and computer readable storage medium
CN113626071A (en) * 2021-08-06 2021-11-09 京东城市(北京)数字科技有限公司 Function registration method, system, electronic device and storage medium
CN114816367A (en) * 2022-05-31 2022-07-29 苏州浪潮智能科技有限公司 OD statement and castable editing method, system, storage medium and device
CN116466932A (en) * 2023-03-27 2023-07-21 飞算数智科技(深圳)有限公司 Database statement generation method and device, storage medium and electronic equipment
CN117235155A (en) * 2023-11-16 2023-12-15 荣耀终端有限公司 Data statistics method, electronic device, and readable storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050102284A1 (en) * 2003-11-10 2005-05-12 Chandramouli Srinivasan Dynamic graphical user interface and query logic SQL generator used for developing Web-based database applications
US20080178079A1 (en) * 2007-01-18 2008-07-24 International Business Machines Corporation Apparatus and method for a graphical user interface to facilitate tuning sql statements
EP2369502A2 (en) * 2009-12-29 2011-09-28 Microgen Aptitude Limited SQL generation
CN105279269A (en) * 2015-10-27 2016-01-27 中通服公众信息产业股份有限公司 SQL generating method and system for supporting table free association
CN107656926A (en) * 2016-07-24 2018-02-02 平安科技(深圳)有限公司 Data query method and device based on sql
CN107679056A (en) * 2017-06-25 2018-02-09 平安科技(深圳)有限公司 Generate method, electronic installation and the readable storage medium storing program for executing of SQL statement
CN107943466A (en) * 2016-10-13 2018-04-20 腾讯科技(深圳)有限公司 Database access statement generation method, device and equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050102284A1 (en) * 2003-11-10 2005-05-12 Chandramouli Srinivasan Dynamic graphical user interface and query logic SQL generator used for developing Web-based database applications
US20080178079A1 (en) * 2007-01-18 2008-07-24 International Business Machines Corporation Apparatus and method for a graphical user interface to facilitate tuning sql statements
EP2369502A2 (en) * 2009-12-29 2011-09-28 Microgen Aptitude Limited SQL generation
CN105279269A (en) * 2015-10-27 2016-01-27 中通服公众信息产业股份有限公司 SQL generating method and system for supporting table free association
CN107656926A (en) * 2016-07-24 2018-02-02 平安科技(深圳)有限公司 Data query method and device based on sql
CN107943466A (en) * 2016-10-13 2018-04-20 腾讯科技(深圳)有限公司 Database access statement generation method, device and equipment
CN107679056A (en) * 2017-06-25 2018-02-09 平安科技(深圳)有限公司 Generate method, electronic installation and the readable storage medium storing program for executing of SQL statement

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110059721A (en) * 2019-03-16 2019-07-26 平安城市建设科技(深圳)有限公司 Floor plan area recognizing method, device, equipment and computer readable storage medium
CN109947790A (en) * 2019-03-19 2019-06-28 优刻得科技股份有限公司 The method, apparatus and non-volatile memory medium of cloud resource management
CN110008232A (en) * 2019-04-11 2019-07-12 北京启迪区块链科技发展有限公司 Generation method, device, server and the medium of structured query sentence
CN110222033A (en) * 2019-05-28 2019-09-10 长沙市海图科技有限公司 Simulation spatial service method, apparatus, equipment and storage medium based on SQL configuration
CN110377429A (en) * 2019-07-24 2019-10-25 深圳乐信软件技术有限公司 A kind of control method, device, server and storage medium that real-time task calculates
CN110413675A (en) * 2019-07-24 2019-11-05 深圳乐信软件技术有限公司 A kind of control method, device, server and storage medium that real-time task calculates
CN110781205A (en) * 2019-09-12 2020-02-11 成都四方伟业软件股份有限公司 JDBC-based database direct-checking method, device and system
CN112650766A (en) * 2019-10-10 2021-04-13 腾讯科技(深圳)有限公司 Database data operation method, system and server
CN112650766B (en) * 2019-10-10 2023-10-13 腾讯科技(深圳)有限公司 Database data operation method, system and server
CN111292721A (en) * 2020-02-20 2020-06-16 深圳壹账通智能科技有限公司 Code compiling method and device and computer equipment
WO2021174756A1 (en) * 2020-03-04 2021-09-10 深圳壹账通智能科技有限公司 Application system deployment method and apparatus, and computer device and storage medium
CN111530082A (en) * 2020-05-25 2020-08-14 网易(杭州)网络有限公司 Editing method and device for judging sentences
CN111797637A (en) * 2020-07-21 2020-10-20 苏州思必驰信息科技有限公司 Interactive labeling method and device
CN112765158A (en) * 2020-12-30 2021-05-07 中国人寿保险股份有限公司上海数据中心 Data modification method and device of database and storage medium
CN112799659A (en) * 2021-01-12 2021-05-14 杨飞 Method, device and terminal for automatically generating data interface without programming
CN113051262A (en) * 2021-04-30 2021-06-29 中国银行股份有限公司 Data quality inspection method, device, equipment and storage medium
CN113051262B (en) * 2021-04-30 2024-01-26 中国银行股份有限公司 Data quality inspection method, device, equipment and storage medium
CN113377615A (en) * 2021-06-08 2021-09-10 上海天旦网络科技发展有限公司 Bypass database monitoring method and system
CN113377615B (en) * 2021-06-08 2022-11-08 上海天旦网络科技发展有限公司 Bypass database monitoring method and system
CN113626071A (en) * 2021-08-06 2021-11-09 京东城市(北京)数字科技有限公司 Function registration method, system, electronic device and storage medium
CN113626071B (en) * 2021-08-06 2024-04-16 京东城市(北京)数字科技有限公司 Function registration method, system, electronic device and storage medium
CN113434133A (en) * 2021-08-27 2021-09-24 深圳市信润富联数字科技有限公司 Application building method, device, equipment and computer readable storage medium
CN114816367A (en) * 2022-05-31 2022-07-29 苏州浪潮智能科技有限公司 OD statement and castable editing method, system, storage medium and device
CN116466932A (en) * 2023-03-27 2023-07-21 飞算数智科技(深圳)有限公司 Database statement generation method and device, storage medium and electronic equipment
CN117235155A (en) * 2023-11-16 2023-12-15 荣耀终端有限公司 Data statistics method, electronic device, and readable storage medium

Similar Documents

Publication Publication Date Title
CN109446218A (en) SQL statement generation method, device and computer readable storage medium
US8949776B2 (en) Gateway consumption framework
US10216826B2 (en) Database query system
CN104133772B (en) Automatic test data generation method
US20170123822A1 (en) Building applications for configuring processes
EP2778929B1 (en) Test script generation system
CN105389251A (en) Structured query language debugger
CN109358851A (en) Creation method, device and the computer readable storage medium of chart components
CN108874924B (en) Method and device for creating search service and computer-readable storage medium
US20180046675A1 (en) Automatic adjustment of an execution plan for a query
CN109471857A (en) Data modification method, device and storage medium based on SQL statement
CN103164455B (en) The optimization method and device of data base
CN110287097A (en) Batch testing method, device and computer readable storage medium
CN110275826A (en) Automated testing method, device and computer readable storage medium
CN104679500B (en) Method and device for realizing automatic generation of entity class
CN111026670B (en) Test case generation method, test case generation device and storage medium
US9542164B1 (en) Managing an application variable using variable attributes
CN107679056B (en) Method for generating SQL (structured query language) statement, electronic device and readable storage medium
CN110825395B (en) Multi-plug-in layered deployment system, device and medium
KR101986476B1 (en) Program writing device
CN103294805A (en) Creation method and device for data warehouse personalized dimension table
CN111831320A (en) Plug-in management method and device, electronic equipment and storage medium
US10310958B2 (en) Recording medium recording analysis program, analysis method, and analysis apparatus
US20040051737A1 (en) Method and system of interface editing and online real-time accessing for a personal mobile device
CN106648338A (en) Method and device for editing data

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination