CN110825764A - SQL script generation method, system, storage medium and processor - Google Patents

SQL script generation method, system, storage medium and processor Download PDF

Info

Publication number
CN110825764A
CN110825764A CN201810812170.8A CN201810812170A CN110825764A CN 110825764 A CN110825764 A CN 110825764A CN 201810812170 A CN201810812170 A CN 201810812170A CN 110825764 A CN110825764 A CN 110825764A
Authority
CN
China
Prior art keywords
splicing
target
added
field
sql script
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.)
Granted
Application number
CN201810812170.8A
Other languages
Chinese (zh)
Other versions
CN110825764B (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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology Co 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201810812170.8A priority Critical patent/CN110825764B/en
Publication of CN110825764A publication Critical patent/CN110825764A/en
Application granted granted Critical
Publication of CN110825764B publication Critical patent/CN110825764B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a method for generating an SQL script, which comprises the following steps: acquiring each object to be added in a target set; analyzing each target field name contained in the target SQL script template corresponding to each object to be added; storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result; and when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set. According to the method, the corresponding fields of the object are spliced and then stored into the first splicing result, the information of a plurality of fields can be stored at one time, and the problem that only one field name data can be inserted at one time, and the generation of the SQL script is long due to slow data insertion is solved.

Description

SQL script generation method, system, storage medium and processor
Technical Field
The invention relates to the technical field of databases, in particular to a method for generating an SQL script, a system storage medium and a processor.
Background
The structured Query language (sql) is a special-purpose programming language, a database Query and programming language, used to access data and Query, update, and manage relational database systems.
When a large amount of data needs to be stored in the database, the executed SQL scripts are put into one transaction to be executed as much as possible for performance, so as to improve the SQL batch insertion performance. Taking the example of using the framework Dapper operation relational database Postgres to insert large-batch data, each field name data in an object is put into a corresponding transaction, and only when all field name data of the object are put into the corresponding transaction, the generation of the SQL script can be completed, so that the generation of the SQL script takes longer time.
Disclosure of Invention
In view of the above problems, the present invention is proposed to provide a method, a system, a storage medium and a processor for generating an SQL script, which overcome or at least partially solve the above problems, and the specific schemes are as follows:
a method for generating an SQL script comprises the following steps:
acquiring each object to be added in a target set;
analyzing each target field name contained in the target SQL script template corresponding to each object to be added;
storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result;
and when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set.
Optionally, in the method, storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field includes:
respectively allocating index values to fields of each object to be added, wherein the fields of each object to be added have the same name as the target fields;
establishing a corresponding relation among the index value, the field name corresponding to the index value and the real value of the field name corresponding to the index value;
and storing the corresponding relation into the target object.
The above method, optionally, further comprises;
and initializing the target object.
Optionally, the method for splicing the field names corresponding to the objects to be added according to a preset splicing rule to obtain a first splicing result includes:
for each object to be added, acquiring each field name corresponding to the object to be added and an index value corresponding to each field name, taking each field name and the index value corresponding to each field name as keywords, and splicing the keywords by adopting preset connectors to obtain a second splicing result;
and splicing the second splicing results to obtain the first splicing result.
Optionally, in the foregoing method, when a splicing completion instruction is detected, invoking a first splicing result and the target object to generate a target SQL script corresponding to the target set, where the method includes:
analyzing each keyword in the first splicing result;
searching a corresponding real value in the target object according to each keyword;
and generating a target SQL script corresponding to the target set according to the first splicing result and the real value corresponding to each keyword in the first splicing result.
A system for generating an SQL script, comprising:
the acquisition module is used for acquiring each object to be added in the target set;
the analysis module is used for analyzing the names of all target fields contained in the target SQL script template corresponding to all the objects to be added;
the storage splicing module is used for storing the real values of the corresponding fields in the objects to be added into the target objects according to the names of the target fields; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result;
and the generating module is used for calling the first splicing result and the target object to generate a target SQL script corresponding to the target set when a splicing completion instruction is detected.
In the foregoing system, optionally, the splicing storage module includes:
the distribution unit is used for distributing index values to fields of each object to be added, wherein the fields of each object to be added have the same name as the target fields;
the establishing unit is used for establishing a corresponding relation among the index value, the field name corresponding to the index value and the real value of the field name corresponding to the index value;
and the storage unit is used for storing the corresponding relation into the target object.
In the foregoing system, optionally, the splicing storage module includes:
the first splicing unit is used for acquiring each field name corresponding to each object to be added and an index value corresponding to each field name for each object to be added, taking each field name and the index value corresponding to each field name as keywords, and splicing the keywords by adopting preset connectors to obtain a second splicing result;
and the second splicing unit is used for splicing the second splicing results to obtain the first splicing result.
A storage medium comprising a stored program, wherein the program executes the above-described SQL script generation method.
A processor is used for running a program, wherein the program runs to execute the SQL script generation method.
By means of the technical scheme, the invention discloses a method for generating an SQL script, which comprises the following steps: acquiring each object to be added in a target set; analyzing each target field name contained in the target SQL script template corresponding to each object to be added; storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result; and when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set. According to the method, the corresponding fields of the object are spliced and then stored into the first splicing result, the information of a plurality of fields can be stored at one time, and the problem that only one field name data can be inserted at one time, and the generation of the SQL script is long due to slow data insertion is solved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flowchart illustrating a method for generating an SQL script disclosed in the embodiments of the present application;
FIG. 2 is a flowchart of another method for generating an SQL script disclosed in the embodiment of the present application;
FIG. 3 is a flowchart of another method for generating an SQL script disclosed in the embodiment of the present application;
FIG. 4 is a flowchart of another method for generating an SQL script disclosed in the embodiment of the present application;
fig. 5 shows a block diagram of a system for generating an SQL script disclosed in an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The invention provides a method for generating an SQL script, which is used in the generation process of the SQL script, wherein an execution main body of the generation method can be a processor, a controller or other preferable execution main bodies, and the inventor researches the existing SQL script generation method to find that only one field name data can be inserted at one time, the data insertion is slow, and only when all the field name data of an object are put into corresponding transactions, the generation of the SQL script can be completed, so that the generation of the SQL script takes longer time, the invention provides a batch-inserted SQL script generation method, which solves the problem of slow generation of the SQL script, and the execution flow of the generation method is shown in figure 1 and comprises the following steps:
s101, obtaining each object to be added in a target set;
in the embodiment of the present invention, the target set is a set that needs to generate an SQL script, the target set includes a plurality of objects to be added, each object includes a plurality of field name information, for example, the target set may be a class, the object to be added may be each student in the class, and the field name may be other preferred field names such as name, age, gender, height, or hobbies of each student.
S102, analyzing the name of each target field contained in the target SQL script template corresponding to each object to be added;
in the implementation of the invention, the names of the target fields needing to be spliced are determined according to the field names and the actual requirements of the objects in the target set, and the names of the target fields contained in the target SQL script template corresponding to the objects to be added are analyzed.
S103, storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result;
in the embodiment of the invention, the real value of the field corresponding to each object in the target set is obtained according to the name of each target field, and each obtained real value is stored in the target object. And splicing the field names corresponding to the objects to be added according to a preset splicing rule, and sequentially adding the field names to a first splicing result, wherein the first splicing result comprises the field names corresponding to the objects to be added in the target set, and the storing and splicing processes have no sequence.
And S104, when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set.
In the embodiment of the invention, when the splicing of each object to be added in the target set is completed, a splicing completion instruction is sent, and when the splicing completion instruction is detected, the first splicing result and the target object are called to generate the target SQL script corresponding to the target set.
Each object does not necessarily contain all the real values corresponding to the target fields, if at least one real value of a target field is lacked in the current object, the real value corresponding to the lacked target field is directly ignored, each object can contain more than one field, one field corresponds to one real value, so that each object contains at least one real value corresponding to the target field, preferably, the field names which do not correspond to any target field in the target fields are ignored and are not spliced, and the corresponding fields with the real values in each object are directly spliced according to a preset splicing rule.
In this embodiment of the present invention, the preferred script template of the target SQL may be:
sqlTemplate=”INSERT INTO public.jobkeyword(jobid,keyword,url,orderid,createtime,isdelete)VALUES({0});”
wherein, jobid, keyword, url, orderid, createtime, isdelete are target field names.
The invention discloses a method for generating an SQL script, which comprises the following steps: acquiring each object to be added in a target set; analyzing each target field name contained in the target SQL script template corresponding to each object to be added; storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result; and when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set. According to the method, the corresponding fields of the object are spliced and then stored into the first splicing result, the information of a plurality of fields can be stored at one time, and the problem that only one field name data can be inserted at one time, and the generation of the SQL script is long due to slow data insertion is solved.
In the embodiment of the present invention, a flow of a method for storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field is shown in fig. 2, and includes the steps of:
s201, respectively allocating index values to fields of each object to be added, wherein the fields of each object to be added have the same name as each target field;
in the embodiment of the present invention, because each object to be added includes a field with the same name, in order to distinguish the fields with the same field name, preferably, an index value is allocated to a corresponding field of each object, taking four objects as an example, a specific allocation process is as follows:
INSERT INTO public.jobkeyword(jobid,keyword,url,orderid,createtime,isdelete)
VALUES(@JobId1,@Keyword2,@Url3,@OrderId4,@CreateTime5,@IsD elete6);
INSERT INTO public.jobkeyword(jobid,keyword,url,orderid,createtime,isdelete)
VALUES(@JobId7,@Keyword8,@Url9,@OrderId10,@CreateTime11,@IsDelete12);
INSERT INTO public.jobkeyword(jobid,keyword,url,orderid,createtime,isdelete)
VALUES(@JobId13,@Keyword14,@Url15,@OrderId16,@CreateTime17,@IsDelete18);
INSERT INTO public.jobkeyword(jobid,keyword,url,orderid,createtime,isdelete)
VALUES(@JobId19,@Keyword20,@Url21,@OrderId22,@CreateTime23,@IsDelete24);
and according to the splicing sequence of the corresponding field names in each object, sequentially distributing an index value to each corresponding field name.
S202, establishing a corresponding relation among the index value, the field name corresponding to the index value and the real value of the field name corresponding to the index value;
in the embodiment of the present invention, in order to obtain the actual value of the corresponding field in the object when the target SQL script is subsequently generated, preferably, the index value, the field name corresponding to the index value, and the actual value of the field name corresponding to the index value are associated with each other, and the corresponding actual value is searched according to the index value and the field name.
S203, storing the corresponding relation into a target object.
In the embodiment of the invention, the corresponding field name of each object and the corresponding relation between the corresponding index value and the real value are stored in the target object. Preferably, the target object is initialized before the correspondence relation is stored for any set.
In the embodiment of the present invention, a method flow for obtaining a first splicing result by splicing the corresponding field names in each object to be added according to a preset splicing rule is shown in fig. 3, and includes the steps of:
s301, aiming at each object to be added, acquiring each field name corresponding to the object to be added and an index value corresponding to each field name, taking each field name and the index value corresponding to each field name as keywords, and splicing the keywords by adopting preset connectors to obtain a second splicing result;
in the embodiment of the invention, each field and index value corresponding to each object to be added are respectively obtained, each field name and the index value corresponding to each field name are used as keywords, and all keywords are spliced by adopting a preset connector, wherein, preferably, the name and the index value are used as the preset connector. Each object corresponds to a second splicing result, wherein the second splicing result is an SQL script.
S302, splicing the second splicing results to obtain the first splicing result. .
In the embodiment of the present invention, preferably, the obtained first and second splicing results are stored in a preset database, and when one second splicing result is generated, the first and second splicing results are spliced and stored in the preset database in an additional manner, and when all the second splicing results are stored, the first splicing result is stored in the preset database. Preferably, each time a new set needs to generate SQL, the first concatenation result is initialized, and the previous storage result is cleared.
In the embodiment of the present invention, when a splicing completion instruction is detected, a method flow for calling a first splicing result and the target object and generating a target SQL script corresponding to the target set is shown in fig. 4, and includes the steps of:
s401, analyzing each keyword in the first splicing result;
in the embodiment of the invention, the keywords corresponding to each corresponding field name in the first splicing result are analyzed.
S402, searching a corresponding real value in the target object according to each keyword;
in the embodiment of the present invention, the actual value corresponding to the field name and the index value included in the key is searched for in the target object, for example, the actual value corresponding to the keyword2 is "buy mobile phone".
S403, generating a target SQL script corresponding to the target set according to the first splicing result and the real value corresponding to each keyword in the first splicing result.
In the embodiment of the invention, according to the second splicing result of each object to be added in the first splicing result and the real value corresponding to each keyword in the first splicing result, a target SQL script corresponding to the target set is generated, each object is used as one piece of data, and the insertion of batch data corresponding to each object to be added is finally realized.
In the embodiment of the present invention, taking the generation process of the SQL script when the popper operates postgres to perform batch insertion of data as an example, the generation process of the SQL script is described, which specifically includes the following steps:
(1) initializing an SQL script template inserted with a single piece of data, and storing the SQL script template by using a character string variable;
(2) defining a character string set in the SQL script template, and initializing each target field name to be added in the set;
(3) initializing a dynamic parameters target object for storing the real value of the variable;
(4) defining a StringBuilder database to store a first splicing result;
(5) circularly acquiring a real value 'PropertyInfo' of each field in each field set through reflection, and caching the real value 'PropertyInfo' in a key-value pair set, wherein key is a field name, and value is PropertyInfo;
(6) defining a variable ' index initial value of an int type to be ' 0 ' for recording a field index;
(7) the loop needs to insert a set of objects, acquire a field value specified by the object, define a list < string > set for storing SQL variable names, loop PropertyInfo, add a string value to the list < string > set as "field name" + index ", and then add" 1 "to the" index ", where in the embodiment of the present invention, the" field name "+ index is defined as a keyword.
(8) Then, the "field name" + index value "which is the actual value of the field is added to the DynamicParameters target object. The actual value is obtained by propertytem.
(9) And then pressing and splicing the list < string > set, and adding the list < string > set to a StringBuilder database to obtain a first splicing result.
(10) And finally realizing the generation completion of the SQL script according to the StringBuilder database and the dynamic parameters target object.
In the embodiment of the present invention, corresponding to the above method for generating an SQL script, the embodiment of the present invention further provides a system for generating an SQL script, where a structural block diagram of the system is shown in fig. 5, and the system includes:
the system comprises an acquisition module 501, an analysis module 502, a storage splicing module 503 and a generation module 504.
Wherein the content of the first and second substances,
the obtaining module 501 is configured to obtain each object to be added in the target set;
the parsing module 502 is configured to parse each target field name included in the target SQL script template corresponding to each object to be added;
the storage concatenation module 503 is configured to store the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result;
the generating module 504 is configured to, when a splicing completion instruction is detected, invoke the first splicing result and the target object, and generate a target SQL script corresponding to the target set.
The invention discloses a generating system of SQL script, which comprises: acquiring each object to be added in a target set; analyzing each target field name contained in the target SQL script template corresponding to each object to be added; storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result; and when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set. According to the system, the corresponding fields of the object are spliced and then stored into the first splicing result, the information of a plurality of fields can be stored at one time, and the problem that only one field name data can be inserted at one time, and the generation of the SQL script is long due to slow data insertion is solved.
In this embodiment of the present invention, the splicing storage module 503 includes:
an allocation unit 505, a building unit 506 and a storage unit 507.
Wherein the content of the first and second substances,
the allocating unit 505 is configured to allocate an index value to each field, which is in the same name as the target field, in each object to be added;
the establishing unit 506 is configured to establish a corresponding relationship among the index value, the field name corresponding to the index value, and the actual value of the field name corresponding to the index value;
the storage unit 507 is configured to store the correspondence relationship into a target object
In this embodiment of the present invention, the splicing storage module 503 includes:
a first stitching unit 508 and a second stitching unit 509.
Wherein the content of the first and second substances,
the first splicing unit 508 is configured to, for each object to be added, obtain each field name corresponding to the object to be added and an index value corresponding to each field name, use each field name and the index value corresponding to the field name as keywords, and splice the keywords with a preset connector to obtain a second splicing result;
the second splicing unit 509 is configured to splice the second splicing results to obtain the first splicing result.
The SQL script generating system comprises a processor and a memory, wherein the acquiring module, the analyzing module, the storing module, the splicing module, the generating module and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more, and the speed of generating the SQL script data insertion is improved by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
An embodiment of the present invention provides a storage medium, on which a program is stored, and the program, when executed by a processor, implements the method for generating the SQL script.
The embodiment of the invention provides a processor, which is used for running a program, wherein the SQL script generation method is executed when the program runs.
The embodiment of the invention provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein the processor executes the program and realizes the following steps:
acquiring each object to be added in a target set;
analyzing each target field name contained in the target SQL script template corresponding to each object to be added;
storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result;
and when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set.
Optionally, in the method, storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field includes:
respectively allocating index values to fields of each object to be added, wherein the fields of each object to be added have the same name as the target fields;
establishing a corresponding relation among the index value, the field name corresponding to the index value and the real value of the field name corresponding to the index value;
and storing the corresponding relation into the target object.
The above method, optionally, further comprises;
and initializing the target object.
Optionally, the method for splicing the field names corresponding to the objects to be added according to a preset splicing rule to obtain a first splicing result includes:
for each object to be added, acquiring each field name corresponding to the object to be added and an index value corresponding to each field name, taking each field name and the index value corresponding to each field name as keywords, and splicing the keywords by adopting preset connectors to obtain a second splicing result;
and splicing the second splicing results to obtain the first splicing result.
Optionally, in the foregoing method, when a splicing completion instruction is detected, invoking a first splicing result and the target object to generate a target SQL script corresponding to the target set, where the method includes:
analyzing each keyword in the first splicing result;
searching a corresponding real value in the target object according to each keyword;
and generating a target SQL script corresponding to the target set according to the first splicing result and the real value corresponding to each keyword in the first splicing result.
The device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device:
acquiring each object to be added in a target set;
analyzing each target field name contained in the target SQL script template corresponding to each object to be added;
storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result;
and when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set.
Optionally, in the method, storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field includes:
respectively allocating index values to fields of each object to be added, wherein the fields of each object to be added have the same name as the target fields;
establishing a corresponding relation among the index value, the field name corresponding to the index value and the real value of the field name corresponding to the index value;
and storing the corresponding relation into the target object.
The above method, optionally, further comprises;
and initializing the target object.
Optionally, the method for splicing the field names corresponding to the objects to be added according to a preset splicing rule to obtain a first splicing result includes:
for each object to be added, acquiring each field name corresponding to the object to be added and an index value corresponding to each field name, taking each field name and the index value corresponding to each field name as keywords, and splicing the keywords by adopting preset connectors to obtain a second splicing result;
and splicing the second splicing results to obtain the first splicing result.
Optionally, in the foregoing method, when a splicing completion instruction is detected, invoking a first splicing result and the target object to generate a target SQL script corresponding to the target set, where the method includes:
analyzing each keyword in the first splicing result;
searching a corresponding real value in the target object according to each keyword;
and generating a target SQL script corresponding to the target set according to the first splicing result and the real value corresponding to each keyword in the first splicing result.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method for generating an SQL script is characterized by comprising the following steps:
acquiring each object to be added in a target set;
analyzing each target field name contained in the target SQL script template corresponding to each object to be added;
storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result;
and when a splicing completion instruction is detected, calling the first splicing result and the target object to generate a target SQL script corresponding to the target set.
2. The method according to claim 1, wherein storing the real value of the corresponding field in each object to be added into the target object according to the name of each target field comprises:
respectively allocating index values to fields of each object to be added, wherein the fields of each object to be added have the same name as the target fields;
establishing a corresponding relation among the index value, the field name corresponding to the index value and the real value of the field name corresponding to the index value;
and storing the corresponding relation into the target object.
3. The method of claim 2, further comprising;
and initializing the target object.
4. The method according to claim 1, wherein the splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result comprises:
for each object to be added, acquiring each field name corresponding to the object to be added and an index value corresponding to each field name, taking each field name and the index value corresponding to each field name as keywords, and splicing the keywords by adopting preset connectors to obtain a second splicing result;
and splicing the second splicing results to obtain the first splicing result.
5. The method of claim 4, wherein when the splicing completion instruction is detected, invoking the first splicing result and the target object to generate a target SQL script corresponding to the target set, comprises:
analyzing each keyword in the first splicing result;
searching a corresponding real value in the target object according to each keyword;
and generating a target SQL script corresponding to the target set according to the first splicing result and the real value corresponding to each keyword in the first splicing result.
6. A system for generating an SQL script, comprising:
the acquisition module is used for acquiring each object to be added in the target set;
the analysis module is used for analyzing the names of all target fields contained in the target SQL script template corresponding to all the objects to be added;
the storage splicing module is used for storing the real values of the corresponding fields in the objects to be added into the target objects according to the names of the target fields; splicing the corresponding field names in the objects to be added according to a preset splicing rule to obtain a first splicing result;
and the generating module is used for calling the first splicing result and the target object to generate a target SQL script corresponding to the target set when a splicing completion instruction is detected.
7. The system of claim 6, wherein the tiled storage module comprises:
the distribution unit is used for distributing index values to fields of each object to be added, wherein the fields of each object to be added have the same name as the target fields;
the establishing unit is used for establishing a corresponding relation among the index value, the field name corresponding to the index value and the real value of the field name corresponding to the index value;
and the storage unit is used for storing the corresponding relation into the target object.
8. The system of claim 6, wherein the tiled storage module comprises:
the first splicing unit is used for acquiring each field name corresponding to each object to be added and an index value corresponding to each field name for each object to be added, taking each field name and the index value corresponding to each field name as keywords, and splicing the keywords by adopting preset connectors to obtain a second splicing result;
and the second splicing unit is used for splicing the second splicing results to obtain the first splicing result.
9. A storage medium characterized by comprising a stored program, wherein the program executes the SQL script generation method according to any one of claims 1 to 5.
10. A processor, wherein the processor is configured to execute a program, wherein the program executes the method for generating the SQL script according to any of claims 1 to 5.
CN201810812170.8A 2018-07-23 2018-07-23 SQL script generation method, system, storage medium and processor Active CN110825764B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810812170.8A CN110825764B (en) 2018-07-23 2018-07-23 SQL script generation method, system, storage medium and processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810812170.8A CN110825764B (en) 2018-07-23 2018-07-23 SQL script generation method, system, storage medium and processor

Publications (2)

Publication Number Publication Date
CN110825764A true CN110825764A (en) 2020-02-21
CN110825764B CN110825764B (en) 2022-07-26

Family

ID=69533610

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810812170.8A Active CN110825764B (en) 2018-07-23 2018-07-23 SQL script generation method, system, storage medium and processor

Country Status (1)

Country Link
CN (1) CN110825764B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111782629A (en) * 2020-06-23 2020-10-16 京东数字科技控股有限公司 Feature processing script generation method and device
CN113742360A (en) * 2021-08-09 2021-12-03 广州市易工品科技有限公司 Method and device for quickly generating SQL (structured query language) script of heterogeneous database based on metadata
CN115314453A (en) * 2022-08-05 2022-11-08 济南浪潮数据技术有限公司 Data transmission method, data sending end, data receiving end and related equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040249830A1 (en) * 2003-06-06 2004-12-09 Dmitry Sonkin Database object script generation method and system
US20050120014A1 (en) * 2003-07-11 2005-06-02 Deffler Tad A. System and method for generating SQL using templates
CN104572122A (en) * 2015-01-28 2015-04-29 中国工商银行股份有限公司 Software application data generating device and method
CN106919374A (en) * 2015-12-28 2017-07-04 北京京东尚科信息技术有限公司 A kind of scenario generation method and device
US20180096001A1 (en) * 2016-09-15 2018-04-05 Gb Gas Holdings Limited System for importing data into a data repository
CN108170809A (en) * 2017-12-28 2018-06-15 平安科技(深圳)有限公司 Build table scenario generation method, device, equipment and computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040249830A1 (en) * 2003-06-06 2004-12-09 Dmitry Sonkin Database object script generation method and system
US20050120014A1 (en) * 2003-07-11 2005-06-02 Deffler Tad A. System and method for generating SQL using templates
CN104572122A (en) * 2015-01-28 2015-04-29 中国工商银行股份有限公司 Software application data generating device and method
CN106919374A (en) * 2015-12-28 2017-07-04 北京京东尚科信息技术有限公司 A kind of scenario generation method and device
US20180096001A1 (en) * 2016-09-15 2018-04-05 Gb Gas Holdings Limited System for importing data into a data repository
CN108170809A (en) * 2017-12-28 2018-06-15 平安科技(深圳)有限公司 Build table scenario generation method, device, equipment and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
郑斌: "反射生成INSERT多个对象的SQL语句(批量插入)", 《HTTPS://WWW.CNBLOGS.COM/ZHENGBIN/P/6855868.HTML》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111782629A (en) * 2020-06-23 2020-10-16 京东数字科技控股有限公司 Feature processing script generation method and device
CN111782629B (en) * 2020-06-23 2024-05-17 京东科技控股股份有限公司 Feature processing script generation method and device
CN113742360A (en) * 2021-08-09 2021-12-03 广州市易工品科技有限公司 Method and device for quickly generating SQL (structured query language) script of heterogeneous database based on metadata
CN113742360B (en) * 2021-08-09 2023-12-29 广州市易工品科技有限公司 Method and device for rapidly generating SQL script of heterogeneous database based on metadata
CN115314453A (en) * 2022-08-05 2022-11-08 济南浪潮数据技术有限公司 Data transmission method, data sending end, data receiving end and related equipment

Also Published As

Publication number Publication date
CN110825764B (en) 2022-07-26

Similar Documents

Publication Publication Date Title
CN110968824B (en) Page data processing method and device
CN110825764B (en) SQL script generation method, system, storage medium and processor
CN110019111B (en) Data processing method, data processing device, storage medium and processor
CN111198772A (en) Method and system for generating application program interface API
CN107391528B (en) Front-end component dependent information searching method and equipment
CN108874379B (en) Page processing method and device
CN114297204A (en) Data storage and retrieval method and device for heterogeneous data source
CN105867886B (en) Method and device for writing table
CN111125087B (en) Data storage method and device
CN109977317B (en) Data query method and device
CN112527792A (en) Data storage method, device, equipment and storage medium
CN110968500A (en) Test case execution method and device
CN110019357B (en) Database query script generation method and device
CN106294700A (en) The storage of a kind of daily record and read method and device
CN110929188A (en) Method and device for rendering server page
CN108121733B (en) Data query method and device
CN112346761B (en) Front-end resource online method, device, system and storage medium
CN106648565B (en) Request sending method and device
CN108228604B (en) Model construction method based on memory object, information query method and device
CN110362595A (en) A kind of SQL statement dynamic analysis method
CN108062329B (en) Data import method and device
CN112749189A (en) Data query method and device
CN116541730A (en) Determination method and device for field value and electronic equipment
CN116257673A (en) Data query method, device, equipment and storage medium based on elastic search
CN116303528A (en) Data exploration method, device and equipment

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
GR01 Patent grant
GR01 Patent grant