CN114860753A - SQL statement generation method, device, equipment, medium and product - Google Patents

SQL statement generation method, device, equipment, medium and product Download PDF

Info

Publication number
CN114860753A
CN114860753A CN202210346409.3A CN202210346409A CN114860753A CN 114860753 A CN114860753 A CN 114860753A CN 202210346409 A CN202210346409 A CN 202210346409A CN 114860753 A CN114860753 A CN 114860753A
Authority
CN
China
Prior art keywords
rule
target
query
sql statement
entity object
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
CN202210346409.3A
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.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
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 China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN202210346409.3A priority Critical patent/CN114860753A/en
Publication of CN114860753A publication Critical patent/CN114860753A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method, a device, equipment, a medium and a product for generating an SQL statement, and relates to the technical field of data processing. The method comprises the following steps: selecting at least one target entity object as an SQL statement query target from at least one preset entity object, wherein each entity object corresponds to a database; configuring at least one target query rule aiming at the entity object from preset query rules; determining a target database corresponding to the target entity object; and generating the SQL statement according to at least one target query rule, the target database and the target entity object. The technical scheme of the invention can solve the technical problem that the SQL statement generation step is too complicated.

Description

SQL statement generation method, device, equipment, medium and product
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to a method, a device, equipment, a medium and a product for generating an SQL statement.
Background
When writing the SQL statement, the standard statement needs to be written according to the SQL syntax, and although each database follows the standard SQL syntax, the writing requirement on the SQL statement is high because the architecture of each database product is different.
In order to reduce the writing requirement of the SQL statement, currently, when the SQL statement is written, a database tool may be used for editing, so as to provide some auxiliary functions for writing, such as writing keyword prompts for the database.
However, this auxiliary function can only be used as a prompt, and the SQL syntax is still familiar with the standard SQL statement, so a simpler SQL statement generation method is needed.
Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment, a medium and a product for generating an SQL statement, which are used for solving the problem that the generation step of the SQL statement is too complicated.
In a first aspect, an embodiment of the present invention provides a method for generating an SQL statement, including: selecting at least one target entity object as an SQL statement query target from at least one preset entity object, wherein each entity object corresponds to a database; configuring at least one target query rule aiming at the entity object from preset query rules; determining a target database corresponding to the target entity object; and generating the SQL statement according to at least one target query rule, the target database and the target entity object.
Optionally, generating the SQL statement according to at least one of the target query rule, the target database, and the target entity object includes: determining the data type of the target database; according to SQL assembly rules corresponding to the data types; and generating the SQL statement according to the SQL assembly rule, the target query rule and the target entity object.
Optionally, when at least two target entity objects are selected from the entity objects, the generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity objects includes: determining association rules of at least two target entity objects, wherein the association rules correspond to the data set form between the at least two target entity objects; and generating the SQL statement according to the association rule, the SQL assembly rule, the target query rule and at least two target entity objects.
Optionally, the association rule includes: an internal connection rule, an external connection rule and a full connection rule; the internal connection rule corresponds to an intersection data set between at least two target entity objects; the external connection rule corresponds to an intersection data set between at least two target entity objects and a complement data set of one target entity object; the full-connection rule corresponds to a full-set data set between at least two of the target entity objects.
Optionally, the query rule includes a uniqueness rule; correspondingly, when the target query rule is the uniqueness rule, generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object includes: determining an identity query code corresponding to the uniqueness rule, wherein the identity query code is used for querying whether the identity of the target entity object is repeated with other target entity objects; and generating the SQL statement according to the identity identification query code and the SQL assembly rule.
Optionally, the query rule includes a non-null rule; correspondingly, when the target query rule is the non-null rule, generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object includes: determining a content detection code corresponding to the uniqueness rule, wherein the content detection code is used for detecting whether preset content of the target entity object is empty; and generating the SQL statement according to the content detection code and the SQL assembly rule.
Optionally, the generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object includes:
determining an SQL statement template to be assembled according to the SQL assembly rule;
and assembling the target query rule and the target entity object into the SQL statement template to be assembled to obtain the SQL statement.
In a second aspect, an embodiment of the present invention further provides an apparatus for generating an SQL statement, where the apparatus includes:
the system comprises an entity object selection unit, a database query unit and a query processing unit, wherein the entity object selection unit is used for selecting at least one target entity object serving as an SQL statement query target from at least one preset entity object, and each entity object corresponds to one database;
the query rule configuration unit is used for configuring at least one target query rule aiming at the entity object from preset query rules;
the database selection unit is used for determining a target database corresponding to the target entity object;
and the statement processing unit is used for generating the SQL statement according to at least one target query rule, the target database and the target entity object.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the SQL statement generation method according to any one of the embodiments of the present invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the SQL statement generation method according to any of the embodiments of the present invention.
In a fifth aspect, an embodiment of the present invention further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program implements the SQL statement generation method according to any of the embodiments of the present invention.
In the embodiment of the invention, after the target entity object serving as the query target of the SQL statement is determined, the query SQL statement can be automatically generated by configuring the query rule and the target database, different syntactic characteristics of databases of different products in a background can be automatically shielded, and the SQL statement can be used even if the database products are unfamiliar, so that the problem that the SQL statement generation step is too complicated is solved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a flowchart of a method for generating an SQL statement according to an embodiment of the present invention;
fig. 2 is a flowchart of another SQL statement generation method according to the second embodiment of the present invention;
fig. 3 is a flowchart of another SQL statement generation method according to the second embodiment of the present invention;
fig. 4 is a flowchart of an SQL statement generation method under multi-entity continuous query according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of an SQL statement generating apparatus according to a fourth embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device 10 implementing an embodiment of the invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance. According to the technical scheme, the data acquisition, storage, use, processing and the like meet relevant regulations of national laws and regulations.
Example one
Fig. 1 is a flowchart of a method for generating an SQL statement according to an embodiment of the present invention, where the method is applicable to a case of generating an SQL query statement of a corresponding entity object in a database, and the method may be executed by an SQL statement generation device, and the SQL statement generation device may be implemented in a form of hardware and/or software. As shown in fig. 1, the method includes:
s110, selecting at least one target entity object as an SQL statement query target from at least one preset entity object, wherein each entity object corresponds to one database.
The target entity object is a query object of an SQL statement, each entity object is deployed in the database, and the corresponding relation between the entity object and the database is established, so that when the target entity object is selected from the database, the target entity object can comprise related information of the database for subsequent processing. When selecting an entity object, one or more target entity objects related to the query need to be selected in their entirety.
S120, configuring at least one target query rule aiming at the entity object from preset query rules.
The query rules are related constraint conditions of query of the entity object, and before SQL statement generation is carried out, a user can configure the query rules according to query requirements and select the required query rules from preset query rules.
S130, determining a target database corresponding to the target entity object.
The entity object and the database have a corresponding relationship, so that the target database corresponding to the target entity object can be determined. Since the generation of the SQL statement needs to combine the related information of the database, it is necessary to determine the target database to be able to generate the corresponding SQL statement. The SQL statements generated between different databases are different in part of the generation syntax, so the final generated SQL statements are also different,
s140, generating the SQL statement according to at least one target query rule, the target database and the target entity object.
The target database can determine special generating grammars aiming at the characteristics of the target database when the SQL sentences are generated, the target entity object is a query target of the SQL sentences, the target query rule is used for performing query configuration according to the requirements of users, and the elements are combined together to generate the query SQL sentences which are wanted by the users according to different databases.
Example two
Fig. 2 is a flowchart of another SQL statement generation method according to the second embodiment of the present invention, and the present embodiment performs optimization based on the foregoing embodiments. As shown in fig. 2, the method includes:
and step 210, determining the data type of the target database.
The data type may be determined according to the name field and the attribute value of the target database, and as described above, the target database may be determined according to the corresponding relationship between the target entity object and the target database.
And step 220, according to the SQL assembly rule corresponding to the data type.
Step 230, generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object.
Because different databases have different implementation architectures and some differences, different databases correspond to different SQL assembly rules when the SQL statements are generated, and different SQL statements can be generated according to different databases when the SQL statements are assembled.
In the second embodiment of the present invention, the query rule includes a uniqueness rule;
correspondingly, when the target query rule is the uniqueness rule, generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object includes:
determining an identity query code corresponding to the uniqueness rule, wherein the identity query code is used for querying whether the identity of the target entity object is repeated with other target entity objects;
and generating the SQL statement according to the identity identification query code and the SQL assembly rule.
The uniqueness rule is used for detecting whether the target entity object meets the uniqueness requirement, namely, no repeated record exists in all record values in the target entity object. For example, the mechanism information table is used, and the mechanism numbers in the mechanism information table do not have a repeated phenomenon, namely the mechanism numbers are regarded as meeting the uniqueness requirement. When generating the SQL statement, the configuration detection object needs to check the uniqueness, and in the output configuration, the content that satisfies the uniqueness rule or the content that does not satisfy the uniqueness rule may be selected.
In the second embodiment of the present invention, the query rule includes a non-null rule;
correspondingly, when the target query rule is the non-null rule, generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object includes:
determining a content detection code corresponding to the uniqueness rule, wherein the content detection code is used for detecting whether preset content of the target entity object is empty;
and generating the SQL statement according to the content detection code and the SQL assembly rule.
The non-null rule is used for checking whether the target entity object meets the non-null requirement, namely, all records do not include null values. Taking the example of the organization information table, the organization name in the organization information table cannot be null. When generating the SQL statement, the configuration detection object needs to check the non-nullability, and in the output configuration, the content that satisfies the non-nullability rule or the content that does not satisfy the non-nullability rule may be selected.
In addition, the query rules are not limited to the two types, and for the applicability and the usability of the rule configuration, the rule configuration templates which can meet most common requirements are extracted from the functional commonality classification of the query, and include configuration templates such as uniqueness check, non-null check, value range check, value constraint check, operation balance check, data format check, total score check, index fluctuation check, custom check and the like.
Fig. 3 is a flowchart of another SQL statement generation method according to the second embodiment of the present invention, and as shown in fig. 3, the method includes the following steps:
and S310, determining an SQL statement template to be assembled according to the SQL assembly rule.
S320, assembling the target query rule and the target entity object into the SQL statement template to be assembled to obtain the SQL statement.
After the configuration of the target query rule is completed, the SQL assembly rule corresponding to the database is determined, the SQL sentence template to be assembled is used for assembling the SQL sentences, and for a user who is unfamiliar with the database, the user can generate the SQL sentences according to the SQL sentence template by only configuring the query rule through the SQL sentence template, so that the syntax characteristics of the databases of different products can be shielded, and the user only needs to pay attention to the required query rule.
The invention can be made into a plug-in form, can be used in the current mainstream B/S software for summarizing and quoting, and has stronger applicability.
EXAMPLE III
Fig. 4 is a flowchart of a method for generating an SQL statement under multi-entity continuous query according to a third embodiment of the present invention, where the third embodiment of the present invention is optimized based on the foregoing embodiments. As shown in fig. 4, when at least two target entity objects are selected from the entity objects, the method includes:
s410, determining association rules of at least two target entity objects, wherein the association rules correspond to a data set form between the at least two target entity objects.
When multi-entity joint query is performed on two or more target entity objects, the target entity objects need to be associated and configured to ensure that the multi-entity joint query does not have a Cartesian product. In short, each member of the two entity objects is associated with any member of the other set. When a developer writes a code, a join condition is usually omitted, so that one piece of data in the set A is triggered to be associated with another element in the set B and then appear in a row of data, and the data are displayed without errors to form a mandatory relationship; therefore, when multi-entity joint query is carried out, configuration of association rules is needed to avoid occurrence of data with no nominal accumulation
S420, generating the SQL statement according to the association rule, the SQL assembly rule, the target query rule and at least two target entity objects.
After the association rule is configured, generating an SQL statement of multi-entity combined query through the association rule, the SQL assembly rule and the target query rule.
In the third embodiment of the present invention, the association rule includes: an internal connection rule, an external connection rule and a full connection rule;
the internal connection rule corresponds to an intersection data set between at least two target entity objects;
the external connection rule corresponds to an intersection data set between at least two target entity objects and a complement data set of one target entity object;
the full-connection rule corresponds to a full-set data set between at least two of the target entity objects.
For example, there are two target entity objects a and B, when the association rule is an internal connection rule, the result of the query only retains the part existing in both a and B, and when the association rule is an external connection rule, the result of the query retains the part existing in both a and B and the remaining part of a or B; when the association rule is an outer connection rule, the query result retains the portions that are present in both A and B and the remaining portions of A and B.
When the connection carries out the joint query of a plurality of entity objects, at least n-1 connection rules are needed. For example: when the number of the target entity objects is 3, at least two connection rules are needed.
Example four
Fig. 5 is a schematic structural diagram of an SQL statement generating apparatus according to a fourth embodiment of the present invention. As shown, the apparatus comprises:
an entity object selecting unit 510, configured to select at least one target entity object serving as an SQL statement query target from at least one preset entity object, where each entity object corresponds to one database;
a query rule configuration unit 520, configured to configure at least one target query rule for the entity object from preset query rules;
a database selecting unit 530, configured to determine a target database corresponding to the target entity object;
a statement processing unit 540, configured to generate the SQL statement according to at least one of the target query rule, the target database, and the target entity object.
In the fourth embodiment of the present invention, the statement processing unit 540 is configured to determine a data type of the target database; according to SQL assembly rules corresponding to the data types; and generating the SQL statement according to the SQL assembly rule, the target query rule and the target entity object.
In the fourth embodiment of the present invention, when at least two target entity objects are selected from the entity objects, the statement processing unit 540 is configured to determine association rules of the at least two target entity objects, where the association rules correspond to a data set format between the at least two target entity objects; and generating the SQL statement according to the association rule, the SQL assembly rule, the target query rule and at least two target entity objects.
In the fourth embodiment of the present invention, the association rule includes: an internal connection rule, an external connection rule and a full connection rule; the internal connection rule corresponds to an intersection data set between at least two target entity objects; the external connection rule corresponds to an intersection data set between at least two target entity objects and a complement data set of one target entity object; the full-connection rule corresponds to a full-set data set between at least two target entity objects.
In the fourth embodiment of the present invention, when the query rule includes a uniqueness rule, the statement processing unit 540 is configured to determine an identity query code corresponding to the uniqueness rule, where the identity query code is configured to query whether an identity of the target entity object is repeated with other target entity objects; and generating the SQL statement according to the identity identification query code and the SQL assembly rule.
In the fourth embodiment of the present invention, when the query rule includes a non-null rule,
a statement processing unit 540, configured to determine a content detection code corresponding to the uniqueness rule, where the content detection code is used to detect whether a preset content of the target entity object is empty; and generating the SQL statement according to the content detection code and the SQL assembly rule.
In the fourth embodiment of the present invention, the statement processing unit 540 is configured to determine, according to the SQL assembly rule, an SQL statement template to be assembled; and assembling the target query rule and the target entity object into the SQL statement template to be assembled to obtain the SQL statement.
The SQL sentence generating device provided by the embodiment of the invention can execute the SQL sentence generating method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
FIG. 6 illustrates a schematic structural diagram of an electronic device 10 that may be used to implement an embodiment of the present invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 6, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM)12, a Random Access Memory (RAM)13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 can perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM)12 or the computer program loaded from a storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data necessary for the operation of the electronic apparatus 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
A number of components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, or the like; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. The processor 11 performs the various methods and processes described above, such as the SQL statement generation method.
In some embodiments, the SQL statement generation method may be implemented as a computer program that is tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the SQL statement generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the SQL statement generation method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
EXAMPLE six
An embodiment of the present invention further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program implements the SQL statement generation method provided in any embodiment of the present application.
Computer program product in implementing the computer program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and including conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments illustrated herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (11)

1. A SQL statement generation method is characterized by comprising the following steps:
selecting at least one target entity object as an SQL statement query target from at least one preset entity object, wherein each entity object corresponds to a database;
configuring at least one target query rule aiming at the entity object from preset query rules;
determining a target database corresponding to the target entity object;
and generating the SQL statement according to at least one target query rule, the target database and the target entity object.
2. The method of claim 1,
generating the SQL statement according to the at least one target query rule, the target database, and the target entity object comprises:
determining the data type of the target database;
according to SQL assembly rules corresponding to the data types;
and generating the SQL statement according to the SQL assembly rule, the target query rule and the target entity object.
3. The method of claim 2, wherein when at least two target entity objects are selected from the entity objects, the generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity objects comprises:
determining association rules of at least two target entity objects, wherein the association rules correspond to the data set form between the at least two target entity objects;
and generating the SQL statement according to the association rule, the SQL assembly rule, the target query rule and at least two target entity objects.
4. The method of claim 3, wherein associating the rule comprises: an internal connection rule, an external connection rule and a full connection rule;
the internal connection rule corresponds to an intersection data set between at least two target entity objects;
the external connection rule corresponds to an intersection data set between at least two target entity objects and a complement data set of one target entity object;
the full-connection rule corresponds to a full-set data set between at least two of the target entity objects.
5. The method of claim 2, wherein the query rule comprises a uniqueness rule;
correspondingly, when the target query rule is the uniqueness rule, generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object includes:
determining an identity query code corresponding to the uniqueness rule, wherein the identity query code is used for querying whether the identity of the target entity object is repeated with other target entity objects;
and generating the SQL statement according to the identity identification query code and the SQL assembly rule.
6. The method of claim 2, wherein the query rule comprises a non-null rule;
correspondingly, when the target query rule is the non-null rule, generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object includes:
determining a content detection code corresponding to the uniqueness rule, wherein the content detection code is used for detecting whether preset content of the target entity object is empty;
and generating the SQL statement according to the content detection code and the SQL assembly rule.
7. The method of claim 2, wherein generating the SQL statement according to the SQL assembly rule, the target query rule, and the target entity object comprises:
determining an SQL statement template to be assembled according to the SQL assembly rule;
and assembling the target query rule and the target entity object into the SQL statement template to be assembled to obtain the SQL statement.
8. An apparatus for generating an SQL statement, the apparatus comprising:
the system comprises an entity object selection unit, a database query unit and a query processing unit, wherein the entity object selection unit is used for selecting at least one target entity object serving as an SQL statement query target from at least one preset entity object, and each entity object corresponds to one database;
the query rule configuration unit is used for configuring at least one target query rule aiming at the entity object from preset query rules;
the database selection unit is used for determining a target database corresponding to the target entity object;
and the statement processing unit is used for generating the SQL statement according to at least one target query rule, the target database and the target entity object.
9. An SQL statement generation electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the SQL statement generation method according to any of claims 1-7 when executing the computer program.
10. A computer-readable storage medium on which a computer program is stored, the program, when executed by a processor, implementing the SQL statement generation method according to any one of claims 1 to 7.
11. A computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the SQL statement generation method according to any of claims 1-7.
CN202210346409.3A 2022-03-31 2022-03-31 SQL statement generation method, device, equipment, medium and product Pending CN114860753A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210346409.3A CN114860753A (en) 2022-03-31 2022-03-31 SQL statement generation method, device, equipment, medium and product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210346409.3A CN114860753A (en) 2022-03-31 2022-03-31 SQL statement generation method, device, equipment, medium and product

Publications (1)

Publication Number Publication Date
CN114860753A true CN114860753A (en) 2022-08-05

Family

ID=82629440

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210346409.3A Pending CN114860753A (en) 2022-03-31 2022-03-31 SQL statement generation method, device, equipment, medium and product

Country Status (1)

Country Link
CN (1) CN114860753A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117056343A (en) * 2023-10-11 2023-11-14 湖北华中电力科技开发有限责任公司 Multi-source data management method and system in power grid field and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117056343A (en) * 2023-10-11 2023-11-14 湖北华中电力科技开发有限责任公司 Multi-source data management method and system in power grid field and electronic equipment
CN117056343B (en) * 2023-10-11 2024-01-23 湖北华中电力科技开发有限责任公司 Multi-source data management method and system in power grid field and electronic equipment

Similar Documents

Publication Publication Date Title
US11119988B2 (en) Performing logical validation on loaded data in a database
CN111708934A (en) Knowledge content evaluation method and device, electronic equipment and storage medium
CN115617888A (en) Data import method, device, equipment, storage medium and product
CN114925143A (en) Method, device, equipment, medium and product for describing logical model blood relationship
US20220067303A1 (en) Conversational syntax using constrained natural language processing for accessing datasets
CN114860753A (en) SQL statement generation method, device, equipment, medium and product
US20240126789A1 (en) Model mining and recommendation engine with simulation interfaces
EP3822818A1 (en) Method, apparatus, device and storage medium for intelligent response
CN116361591A (en) Content auditing method, device, electronic equipment and computer readable storage medium
CN115455091A (en) Data generation method and device, electronic equipment and storage medium
CN114780550A (en) Automatic updating method, device, equipment and medium for element positioning path
KR20220024251A (en) Method and apparatus for building event library, electronic device, and computer-readable medium
CN114048315A (en) Method and device for determining document tag, electronic equipment and storage medium
CN113821533B (en) Method, device, equipment and storage medium for data query
CN113901094B (en) Data processing method, device, equipment and storage medium
CN112445892B (en) Method, device, electronic equipment and storage medium for determining brand mention rate
CN115511014B (en) Information matching method, device, equipment and storage medium
CN112307050B (en) Identification method and device for repeated correlation calculation and computer system
CN114281981A (en) News briefing generation method and device and electronic equipment
CN117743374A (en) Database text query method, device and equipment based on data examples
CN118277406A (en) SQL sentence generation method and device based on large language model
CN114416678A (en) Resource processing method, device, equipment and storage medium
CN117555897A (en) Data query method, device, equipment and storage medium based on large model
CN115525614A (en) Data access method, device, equipment, system and storage medium
CN116595029A (en) Automatic SQL sentence generation method and related 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