Database query method and device, equipment and storage medium

By selecting the operation type, database table name and database fields in the watch face interface, and generating and executing textual query statements, the problem of users needing to be familiar with the database query language is solved, and the user experience is improved.

CN119719137APending Publication Date: 2025-03-28GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411840239.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the prior art, users need to be familiar with the database query language and use them to configure query conditions, resulting in a poor user experience.

Method used

By selecting the operation type, database table name, and database fields in the watch face interface, a textual query statement is generated, and the statement is displayed in the database language area, and the query results are executed.

Benefits of technology

There is no need for users to have a high professional foundation in the database query language, and query statements can be generated and executed through intuitive interface operations, improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719137A_ABST
    Figure CN119719137A_ABST
Patent Text Reader

Abstract

The invention relates to a database query method and device, equipment and a storage medium. The method comprises the steps of connecting a database; displaying a plurality of operation type buttons in the operation type selection area and detecting the selected operation type buttons; displaying a plurality of database table names in the first variable selection area and determining the selected database table name as a to-be-queried table name; displaying a plurality of database fields corresponding to the to-be-queried table name in a second variable selection area, and determining the selected database field as a to-be-queried field; according to the operation type corresponding to the operation type button selected in sequence, the to-be-queried table name and the to-be-queried field, generating a textual query statement, and displaying the textual query statement in a database language area; and executing the textualized query statement and displaying a database query result corresponding to the textualized query statement in a result display area. The method does not need to have a high professional basis for database query languages, is convenient to operate and easy to master, and has good user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a database query method, device, equipment and storage medium. Background Art

[0002] At present, in order to facilitate the query of data in the database, a graphical database query tool is specially designed. The graphical database query tool provides a static interface, in which a drop-down box and a text box are set. The user can select a database table in the drop-down box and enter the query conditions configured by the database query language in the text box for the database table, such as the query conditions configured by SQL (Structured Query Language). Although the graphical database query tool can provide users with an intuitive query interface, it requires users to be familiar with the database query language and be able to use the database query language to configure the query conditions, resulting in a poor user experience. Summary of the invention

[0003] The present application provides a database query method, apparatus, device and storage medium to solve the problem that users are required to be familiar with a database query language and use the database query language to configure query conditions, resulting in a poor user experience.

[0004] In view of the above technical problems, the technical solution of this application is solved by the following embodiments:

[0005] The embodiment of the present application also provides a database query method, including: connecting to a preset database; displaying multiple operation type buttons in a preset operation type selection area and detecting a selected operation type button; displaying multiple database table names in a preset first variable selection area and determining the selected database table name as the table name to be queried; displaying multiple database fields corresponding to the table name to be queried in a preset second variable selection area and determining the selected database field as the field to be queried; generating a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, and displaying the textual query statement in a preset database language area; executing the textual query statement and displaying the database query result corresponding to the textual query statement in a preset result display area.

[0006] Among them, the displaying of multiple database table names in a preset first variable selection area and determining the selected database table name as the table name to be queried includes: determining the query frequencies corresponding to the multiple database table names respectively according to the stored historical query information; in a preset selection suggestion area, displaying a preset number of the database table names in descending order of query frequency; and using the database table name selected in the selection suggestion area as the table name to be queried; or, in the first variable selection area, obtaining text input information; among the multiple database table names displayed, retaining the database table name that matches the text input information; and using the selected database table name among the database table names that match the text input information as the table name to be queried.

[0007] Among them, the generating of a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the name of the table to be queried and the field to be queried includes: generating an initial query statement according to the operation type corresponding to the operation type button selected in sequence, the name of the table to be queried and the field to be queried; generating execution plan information corresponding to the initial query statement; extracting operation information corresponding to the initial query statement from the execution plan information; determining execution cost information corresponding to the execution plan information according to the operation information corresponding to the initial query statement; adjusting the initial query statement according to the execution cost information to obtain the textual query statement.

[0008] Among them, the initial query statement is generated according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, including: generating an original query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried; receiving a filtering condition in a preset historical result calling area; displaying at least one historical query record in the historical query information that meets the filtering condition in the historical result calling area; wherein the historical query record records the operation type, database table, database field, textual query statement and database query result corresponding to at least one database query; determining the historical query record selected in the historical result calling area; connecting the textual query statement in the selected historical query record to the original query statement to form the initial query statement.

[0009] Among them, the generating of the original query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried includes: for each group of the operation type, the table name to be queried and the field to be queried selected in sequence, performing the following operations: setting the operation type, the table name to be queried and the field to be queried selected in sequence in this group as the contents of different identification blocks respectively; sequentially connecting the identification blocks corresponding to the operation type, the table name to be queried and the field to be queried respectively, and encapsulating each of the sequentially connected identification blocks in the statement block corresponding to the operation type in this group to obtain the statement block corresponding to this group; connecting the statement blocks corresponding to each group according to the selection order of each group to form the original query statement.

[0010] Among them, in the process of displaying the textual query statement in the preset database language area, it also includes: at each of the identification blocks, detecting a preset adjustment trigger event; for the identification block where the adjustment trigger event is detected, performing an adjustment operation on the content of the identification block and updating the textual query statement; and, at each of the statement blocks, detecting a preset move trigger event; for the statement block where the move trigger event is detected, performing a move operation and updating the textual query statement.

[0011] Among them, in the process of displaying the database query results corresponding to the textual query statement in the preset result display area, it also includes: in the preset result analysis area, detecting the input analysis information; wherein the analysis information includes analysis type and / or modeling information; in the result analysis area, according to the analysis information, displaying the database query results and performing interactive operations on the database query results.

[0012] The embodiment of the present application also provides a database query device, including: a connection module, used to connect to a preset database; a selection module, used to display multiple operation type buttons in a preset operation type selection area and detect the selected operation type button; display multiple database table names in a preset first variable selection area and determine the selected database table name as the table name to be queried; and, display multiple database fields corresponding to the table name to be queried in a preset second variable selection area and determine the selected database field as the field to be queried; a generation module, used to generate a text query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, and display the text query statement in a preset database language area; a query module, used to execute the text query statement and display the database query result corresponding to the text query statement in a preset result display area.

[0013] An embodiment of the present application also provides a database query device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to: execute a database query program stored in the memory to implement any of the above-mentioned database query methods.

[0014] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed to implement any of the above-mentioned database query methods.

[0015] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application can connect to a preset database; display multiple operation type buttons in a preset operation type selection area and detect the selected operation type button; display multiple database table names in a preset first variable selection area and determine the selected database table name as the table name to be queried; display multiple database fields corresponding to the table name to be queried in a preset second variable selection area and determine the selected database field as the field to be queried; generate a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, and display the textual query statement in a preset database language area; execute the textual query statement and display the database query result corresponding to the textual query statement in a preset result display area. The embodiment of the present application provides a dial interface, in which the required visualization parameters can be selected in the selection area and a textual query statement can be generated, and the textual query statement can also be viewed in the database language area, which is convenient for users to analyze the current textual query statement, and the database query result can also be displayed in the result display area, which is convenient for users to perform subsequent analysis. The database query method of the embodiment of the present application does not require the user to have a high level of professional knowledge of the database query language. A more intuitive textual query statement can be generated simply by selecting visualization parameters in the dial interface. The operation is convenient and easy to master, and the user experience is good. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0019] Figure 1 is a flowchart of a database query method according to an embodiment of the present application;

[0020] Figure 2 is a schematic diagram of a dial interface for database query according to an embodiment of the present application;

[0021] Figure 3 A flowchart of steps for generating a textual query statement according to an embodiment of the present application;

[0022] Figure 4 A flowchart of the steps for generating an initial query statement according to an embodiment of the present application;

[0023] Figure 5 A flowchart of steps for generating an original query statement according to an embodiment of the present application;

[0024] Figure 6 is a structural diagram of a database query device according to an embodiment of the present application;

[0025] Figure 7 4 is a structural diagram of a database query device according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0027] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0028] The present application embodiment provides a database query method. Figure 1 , which is a flow chart of a database query method according to an embodiment of the present application.

[0029] Step S110, connecting to a preset database.

[0030] Connect to the database according to the address, username and password corresponding to the database.

[0031] The database includes multiple database tables. Each database has a database table name and multiple database fields. The database may be a relational database.

[0032] Step S120: display a plurality of operation type buttons in a preset operation type selection area and detect a selected operation type button.

[0033] The operation type selection area is used to display operation type buttons corresponding to multiple operation types.

[0034] The operation type button is a concrete virtual button of the corresponding operation type.

[0035] Types of operation types include, but are not limited to: query, join, sort, modify, group, delete, and sort.

[0036] Step S130: display multiple database table names in a preset first variable selection area and determine the selected database table name as the table name to be queried.

[0037] The first variable selection area is used to display the database table names corresponding to the various database tables in the currently connected database.

[0038] The table name to be queried refers to the data object of this database query.

[0039] Step S140: displaying a plurality of database fields corresponding to the table name to be queried in a preset second variable selection area and determining the selected database field as the field to be queried.

[0040] The first variable selection area is used to display various database fields in the database table corresponding to the table name to be queried.

[0041] The field to be queried refers to the data object of this database query. In other words, the data object of this database query includes: the table name to be queried and the field to be queried.

[0042] Step S150 , generating a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, and displaying the textual query statement in a preset database language area.

[0043] The textual query statement refers to a statement expressed in text, which is composed of the operation type corresponding to the operation type buttons selected in sequence, the name of the table to be queried, and the field to be queried.

[0044] The database language area is used to display the generated text query statements so that users can view the text query statements currently being constructed.

[0045] The operation type, the table name to be queried and the field to be queried corresponding to the operation type button selected sequentially refer to: the selection order of the operation type, the table name to be queried and the field to be queried; wherein, the number of the operation type, the table name to be queried and the field to be queried is at least one, and the selection order of the operation type, the table name to be queried and the field to be queried is not fixed.

[0046] Furthermore, the embodiment of the present application provides three selection areas, each for selecting different parameters. The parameters selected in the operation type selection area, the first variable selection area, and the second variable selection area can be monitored in real time. The types of parameters include: operation type, table name to be queried, and field to be queried. According to the selection order of each parameter, a text query statement is generated and displayed in the database language area.

[0047] For example: In order from first to last, select "query" for the operation type, "employee table" for the table name to be queried, and "id", "name", and "customer age" for the fields to be queried.

[0048] Furthermore, in the process of continuously selecting parameters in the operation type selection area, the first variable selection area and the second variable selection area, in order to facilitate the user to observe the evolution of the text query statement, a text query statement can be generated in real time according to the parameters selected in real time and displayed in the database language area in real time.

[0049] Step S160 , executing the textual query statement and displaying the database query result corresponding to the textual query statement in a preset result display area.

[0050] The result display area is used to display the database query results returned after executing the text query statement for users to view and use.

[0051] Executing the textual query statement includes: converting the textual query statement into a database query statement and executing the database query statement. The database query statement is, for example, an SQL statement.

[0052] Furthermore, database query parameters corresponding to each operation type can be pre-set, and the operation type can be converted into corresponding database query parameters; since the first variable selection area and the second variable selection area are set separately, during the selection process, it is possible to identify whether the selected parameter is the table name to be queried or the field to be queried based on the selected position of the parameter, and then based on the sequential position of the operation type, the table name to be queried and the field to be queried in the textual query statement, the user-recognizable textual query statement can be converted into a computer-recognizable database query statement.

[0053] In an embodiment of the present application, a preset database is connected; multiple operation type buttons are displayed in a preset operation type selection area and the selected operation type button is detected; multiple database table names are displayed in a preset first variable selection area and the selected database table name is determined as the table name to be queried; multiple database fields corresponding to the table name to be queried are displayed in a preset second variable selection area and the selected database field is determined as the field to be queried; according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, a textual query statement is generated and the textual query statement is displayed in a preset database language area; the textual query statement is executed and the database query result corresponding to the textual query statement is displayed in a preset result display area. An embodiment of the present application provides a dial interface, in which the required visualization parameters can be selected in the selection area and a textual query statement can be generated, and the textual query statement can also be viewed in the database language area, so that the user can analyze the current textual query statement conveniently, and the database query result can also be displayed in the result display area, so that the user can conduct subsequent analysis conveniently. The database query method of the embodiment of the present application does not require the user to have a high level of professional knowledge of the database query language. A more intuitive textual query statement can be generated simply by selecting visualization parameters in the dial interface. The operation is convenient and easy to master, and the user experience is good.

[0054] In order to make the embodiments of the present application easier to understand, the database query method of the embodiments of the present application will be further described below. Figure 2 Shown is a schematic diagram of a dial interface for database query according to an embodiment of the present application.

[0055] In an embodiment of the present application, the database query method can be implemented by an application. After the application is started, the database connection information (address, user name and password) used last time can be read, and an attempt can be made to establish a database connection with the database. After the application is started, the database connection information can also be set in the application, and a database connection can be established with the corresponding database according to the database connection information.

[0056] In an embodiment of the present application, a plurality of operation type buttons having a preset number of buttons arranged according to query frequency may be displayed in the operation type selection area.

[0057] Specifically, a database query log is obtained; each operation type is identified in the database query log and the query frequency corresponding to each operation type is determined; in the order of query frequency from high to low, operation type buttons corresponding to a preset number of operation types are arranged in the operation type selection area. Alternatively, a hook function is pre-set, and in the process of querying the database, the query frequency corresponding to each operation type is counted by using the hook function; in the order of query frequency from high to low, operation type buttons corresponding to a preset number of operation types are arranged in the operation type selection area.

[0058] The database query log is used to record the query information each time the database is queried. The query information at least includes: the operation type.

[0059] The preset number of buttons may be an empirical value or a value obtained through experiments. The preset number of buttons may be set according to the size of the screen.

[0060] Furthermore, when determining the query frequency corresponding to each operation type, a pre-trained model can be used to determine the query frequency corresponding to each operation type based on the database query log. Further, the model can be trained to identify the operation type involved in each database query in the query log and calculate the query frequency corresponding to each operation type.

[0061] Furthermore, when arranging the operation type buttons corresponding to the operation types of the preset number of buttons, the operation types can be sorted in descending order according to the query frequencies corresponding to the operation types, and the operation types of the previous preset number of buttons can be obtained; and the operation type buttons corresponding to the operation types of the previous preset number of buttons can be set in the operation type selection area according to the preset button layout. In this way, the operation type buttons that users use most often can be found more easily and accessed more easily.

[0062] The button layout mode can be an adaptive layout mode. This adaptive layout mode can use the React framework combined with CSS (Cascading Style Sheets) and Flexbox technology to dynamically adjust the position of each operation type button in the operation type selection area. In the CSS file, set different layout styles for different screen sizes. For example: small screen devices (<600px): set the operation type button width to 100%, and display one operation type button per line; medium screen devices (601px-1024px): set the operation type button width to 50%, and display two button operation types per line; large screen devices (>1024px): set the operation type button width to 25%, and display four button operation types per line. In the CSS file, use the Flexbox attribute to set the layout mode of the button container. For example, set display:flex, flex-wrap:wrap and justify-content:center to ensure that the operation type buttons can be arranged reasonably under different screen sizes. At the same time, setting appropriate Flexbox attributes for the operation type buttons can make the operation type buttons automatically adjust their size on different devices.

[0063] Furthermore, when arranging operation type buttons corresponding to the operation types of the preset number of buttons, the operation type buttons corresponding to the operation types with a query frequency greater than the preset frequency threshold can be set to a preset style, for example, set to a bright color so that the user can see the operation type button more quickly.

[0064] In the embodiment of the present application, after the operation type selection area displays a preset number of operation type buttons, the user can select the desired operation type button in the operation type selection area. Generally speaking, when constructing a text query statement, the user needs to first select an operation type button, and then select the database table name and the database field corresponding to the database table name in sequence after selecting the operation type button.

[0065] In the embodiment of the present application, multiple database table names are displayed in the first variable selection area and the selected database table name is determined as the table name to be queried. Three methods of determining the table name to be queried are provided below.

[0066] Method 1: Display all database table names in the currently connected database in the display area of ​​the first variable selection area, detect one of the selected database table names, and determine the selected database table name as the table name to be queried.

[0067] Method 2: Since there may be a large number of database tables in the currently connected database, it is not convenient for the user to find the database table name to be queried among the numerous database table names, so selection suggestions can be provided to the user, and the user locates the database to be queried according to the selection suggestions. For this method 2, the query frequencies corresponding to the multiple database table names can be determined according to the stored historical query information; in the preset selection suggestion area, a preset number of the database table names are displayed in sequence according to the query frequency from large to small; and the database table name selected in the selection suggestion area is used as the table name to be queried.

[0068] The historical query information is used to record the historical query records for the currently connected database. The historical query records at least include: the operation type used when querying the database, the database table name and database field queried, the text query statement executed, and the database query result.

[0069] The selection suggestion area is used to provide high-frequency database table names to be selected, so as to provide suggestions for users to select database table names.

[0070] Furthermore, the database table name displayed in the selection suggestion area and the same database table name displayed in the first variable selection area are linked, and if the database table name displayed in the selection suggestion area is selected, the same database table name displayed in the first variable selection area is selected.

[0071] Method three: since there may be a large number of database tables in the currently connected database, it is not convenient for the user to find the database table name to be queried among the numerous database table names. Therefore, in order to narrow the search scope, text input information can also be obtained in the first variable selection area; among the multiple database table names displayed, the database table name that matches the text input information is retained; and the database table name selected from the database table names that match the text input information is used as the table name to be queried.

[0072] Furthermore, a text input box may be set in the first variable selection area to obtain text input information input in the text input box.

[0073] Furthermore, the text input information is fuzzily matched with each database table name displayed in the first variable selection area to obtain a database table name that matches the text input information, and only the database table name that matches the text input information is displayed in the first variable selection area. In this way, the number of database table names displayed in the first variable selection area is reduced, and the displayed database table names are more in line with user needs, so it can help users quickly find the database table name they need to query. For example: if the user enters "customer satisfaction", then "customer" can be matched to the database table name, and "satisfaction" can be matched to the database field.

[0074] Furthermore, if there is no database table name matching the text input information, a corresponding prompt message is popped up to inform the user that the database table name does not exist.

[0075] Furthermore, the fuzzy matching algorithm includes but is not limited to: Levenshtein distance algorithm or Jaccard similarity algorithm.

[0076] In an embodiment of the present application, after one of the database table names is selected as the table name to be queried, multiple database fields corresponding to the table name to be queried can be displayed in a preset second variable selection area and the selected database field can be determined as the field to be queried. The number of the fields to be queried is at least one.

[0077] Furthermore, the database field may be selected in the same manner as selecting a database table name.

[0078] For example: directly display multiple database fields corresponding to the database table name, and directly select the required database field as the field to be queried.

[0079] For another example: the query frequencies corresponding to the multiple database fields corresponding to the table name to be queried can be determined based on the stored historical query information; in a preset selection suggestion area, a preset number of the database fields are displayed in sequence in descending order of query frequency; and the database field selected in the selection suggestion area is used as the field to be queried.

[0080] For another example: in the second variable selection area, text input information is obtained; among the multiple database fields displayed, the database field matching the text input information is retained and displayed; and the database field selected from the database fields matching the text input information is used as the field to be queried. Furthermore, if there is no database field matching the text input information, a corresponding prompt message is popped up to inform the user that the database field does not exist.

[0081] In the embodiment of the present application, after selecting the operation type, the table name to be queried, and the field to be queried, other operation types, other table names to be queried, and other fields to be queried may be selected in sequence to form sequentially selected operation types, table names to be queried, and fields to be queried. That is to say, among the sequentially selected operation types, table names to be queried, and fields to be queried, the number of operation types is at least one, the number of table names to be queried is at least one, and the number of fields to be queried is also at least one, and the selected operation types, table names to be queried, and fields to be queried are arranged in the order of selection.

[0082] In an embodiment of the present application, in the process of selecting the operation type, the table name to be queried, and the field to be queried, the type of operation type button displayed in the operation type selection area can be adjusted according to the current selection, and the next operation type button recommendation can be made.

[0083] Furthermore, the operation type button to be used after the operation type button is selected is determined in advance and associated, the operation type button to be used after the table name to be queried is determined and associated; the operation type button to be used after the field to be queried is determined and associated. After determining that an operation type button is currently selected, the operation type button associated with the operation type is displayed in the front position in the operation type selection area; after determining that a database table name is currently selected, the operation type button associated with the table name to be queried is displayed in the front position in the operation type selection area; after determining that a database field is currently selected, the operation type button associated with the field to be queried is displayed in the front position in the operation type selection area. In the case of a large number of operation type buttons, by adjusting the operation type buttons displayed in the operation type selection area in real time, it is convenient for users to locate the required operation type buttons and avoid the problem of difficulty in finding the operation type buttons.

[0084] For example: the user selects a database field in the second variable selection area. At this time, the operation type selection area adjusts the order of the operation type buttons and moves the positions of the operation type buttons that may be used, such as "add aggregate function" and "set sorting conditions", to the front.

[0085] In the embodiment of the present application, in the process of selecting the operation type, the table name to be queried, and the field to be queried, the selection suggestions provided in the selection suggestion area can be adjusted according to the current selection. Furthermore, the selection recommendation model can be trained in advance using historical query information, so that the selection recommendation model can recommend the next database table name and / or database field based on the currently constructed partial text query statement and display it in the selection suggestion area, so as to help the user construct a complete text query statement.

[0086] In an embodiment of the present application, a textual query statement may be generated according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried, and the field to be queried.

[0087] A textual query statement refers to a database query statement constructed in text form. Since the textual query statement does not use a database query language, such as SQL, the textual query statement is more intuitive and easy to understand, and is more friendly to users who are not familiar with database query languages.

[0088] Figure 3The present invention is a flowchart of the steps for generating a textual query statement according to an embodiment of the present application.

[0089] Step S310, generating an initial query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried.

[0090] The initial query statement is a textual query statement that has not been optimized. The textual query statement that has not been optimized may have defects, which may lead to poor query performance and even performance bottlenecks. Therefore, the embodiment of the present application optimizes the cost of the initial query statement, improves the performance of the initial query statement, and uses the optimized initial query statement as the textual query statement.

[0091] The steps of how to generate the initial query statement in the embodiment of the present application will be described later, so they will not be repeated here.

[0092] Step S320: Generate execution plan information corresponding to the initial query statement.

[0093] The execution plan information is used to describe the process of executing a database query based on the initial query statement.

[0094] Execution plan information is usually displayed in a graphical or textual form, consisting of multiple nodes and arrows. Each node represents an operation, and the arrows represent the flow of data between operations.

[0095] Furthermore, a preset query optimizer may be called to generate an execution plan for an SQL statement using a database API or a preset command.

[0096] Step S330: extracting operation information corresponding to the initial query statement from the execution plan information.

[0097] The operation information includes but is not limited to: the operation content and resource consumption corresponding to each operation, wherein each operation corresponds to a part of the initial query statement.

[0098] Operation content includes, for example, I / O operation, index scan, etc. Resource consumption includes, for example, CPU usage, memory usage, etc.

[0099] Furthermore, the execution plan information may be parsed using a parsing library, such as the sqlparse library provided by Python, so as to extract the operation information corresponding to the initial query statement.

[0100] Step S340: determining execution cost information corresponding to the execution plan information according to the operation information corresponding to the initial query statement.

[0101] The types of indicators in the execution cost information include, but are not limited to: the number of I / O operations, CPU usage, and memory usage corresponding to each operation in the execution plan information.

[0102] Step S350: adjusting the initial query statement according to the execution cost information to obtain the textual query statement.

[0103] The execution cost information can be analyzed using a preset analysis tool to locate abnormal operations in the execution plan information. Furthermore, under normal circumstances, the indicator should be within a preset value range. If it exceeds the value range, it can be determined that the operation is abnormal.

[0104] Adjust some initial query statements corresponding to abnormal operations. Specifically, detect whether there is preset bottleneck information in some execution plan information corresponding to the initial query statements; display corresponding optimization suggestion information in the database language area for the bottleneck information; detect adjustment trigger events based on the optimization suggestion information; adjust the initial query statements according to the detected adjustment trigger events to obtain textual query statements.

[0105] Bottleneck information includes but is not limited to: "full table scan", "subquery", and "JOIN operation". Among them, "JOIN operation" refers to a join operation. "Subquery" refers to a subquery with low query efficiency, for example, the query time of the subquery exceeds the preset query time threshold. "JOIN operation" refers to a join operation with low join efficiency, for example, the join time of the JOIN operation exceeds the preset join time threshold.

[0106] For full table scans, the optimization suggestion information is the SQL statement for creating an index, which can avoid full table scans. For example, the SQL statement for creating an index is: CREATE INDEXidx_order_date ON orders(order_date).

[0107] For subqueries, the optimization suggestion information is to issue a rewrite query message and use JOIN instead of the subquery to obtain data more efficiently. The rewrite query message is used to prompt that the part of the initial query statement needs to be rewritten. An example of the rewritten query can be provided in the rewrite query message.

[0108] For JOIN operations, the optimization recommendation information creates indexes for the fields of the JOIN operation.

[0109] The following describes the steps of how to generate an initial query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried. Figure 4 The figure is a flow chart of the steps for generating an initial query statement according to an embodiment of the present application.

[0110] Step S410, generating an original query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried.

[0111] The original query statement refers to an unoptimized textual query statement that can be directly generated according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried.

[0112] The steps of how to generate the original query statement in the embodiment of the present application will be described later, so they will not be repeated here.

[0113] Step S420, receiving filtering conditions in a preset historical result calling area.

[0114] The historical result call area is used to provide historical query records for call according to user needs.

[0115] The filtering condition is used to filter out the historical query records that meet the user's needs from the historical query information. The filtering condition includes but is not limited to: the label, version information, execution time and included content of the historical query record.

[0116] In an embodiment of the present application, a filter condition input box may be provided in the historical result calling area, and the user may enter the desired filter condition in the filter condition input box.

[0117] In an embodiment of the present application, various optional tags can be displayed in the historical result call area. Each tag corresponds to a set of historical query records. The user can select one of the tags, which is equivalent to entering a filtering condition so that the various historical query records stored under the tag can be viewed.

[0118] Step S430, in the historical result calling area, at least one historical query record in the historical query information that meets the filtering condition is displayed; wherein the historical query record records at least one operation type, database table, database field, textual query statement and database query result corresponding to a database query. The database table name and database field are the table name and field to be queried when executing the database query.

[0119] Step S440, determining the selected historical query record in the historical result calling area.

[0120] The user can select the required historical query record from the various historical query records displayed in the historical result call area as needed.

[0121] Step S450: Connect the textual query statement in the selected historical query record to the original query statement to form the initial query statement.

[0122] Specifically, since the operation type sequence specified by the database standard syntax is: the operation types in the query statement are in the following order from front to back: SELECT, FROM, JOIN, WHERE and GROUP BY. Among them, SELECT represents the selection operation type, and the table name to be queried corresponding to the selection operation type is the table name of the main database table; FROM represents the database table to be retrieved; JOIN represents the connection operation type; WHERE represents the conditional operation type; GROUP BY represents the grouping operation type. The textual query statement can be obtained in the historical query record; the selection operation type corresponding to the main database table name in the textual query statement is identified; the selection operation type is adjusted to a connection operation type or a conditional operation type; the adjusted textual query statement is connected to the original query statement to form an initial query statement, thereby realizing the call to the historical query record.

[0123] Further, the selection operation type can be adjusted to one of the connection operation type and the conditional operation type; after the operation type is adjusted, an adjustment trigger event triggered for the adjusted operation type is detected; if the adjustment trigger event is detected, the adjusted operation type is adjusted to the other of the connection operation type and the conditional operation type. The specific adjustment process will be described later, so it is not repeated here.

[0124] In the embodiment of the present application, if there is no need to refer to the historical query record, that is, if there is no need to connect the original query statement to the textual query statement in the historical query record, the original query statement can be directly used as the initial query statement.

[0125] In an embodiment of the present application, in addition to narrowing the scope of historical query records according to the filtering conditions to facilitate the user to locate the required historical query records, it is also possible to query the historical query records that match the selected operation type, the table name to be queried, and the field to be queried in the historical query information, and display the matched historical query records in the historical result call area. It is also possible to query the labels that match the selected operation type, the table name to be queried, and the field to be queried in the labels set for each historical query record, and display each historical query record corresponding to the label in the historical result call area. In this way, an intelligent recommendation method can be provided to the user, providing the user with reference options suitable for the current database query, thereby improving the database query performance.

[0126] The following describes the steps of generating an original query statement according to the operation type corresponding to the operation type buttons selected in sequence, the name of the table to be queried and the field to be queried.

[0127] Specifically, the operation type sequence SELECT, FROM, JOIN, WHERE and GROUP BY can be used according to the standard syntax of the database. In the operation type corresponding to the sequentially selected operation type button, the name of the table to be queried and the field to be queried, SELECT, FROM, JOIN, WHERE and GROUP BY are identified, and the fields to which SELECT, FROM, JOIN, WHERE and GROUP BY belong respectively can be regarded as one group. Of course, a button for users to divide groups can also be set in the operation type selection area. In the process of the operation type corresponding to the sequentially selected operation type button, the name of the table to be queried and the field to be queried, the groups can be divided by this button.

[0128] For each group of the operation type, the table name to be queried, and the field to be queried selected in sequence, execute Figure 5 The steps shown in the figure are as follows. Figure 5 It is a flow chart of the steps for generating an original query statement according to an embodiment of the present application.

[0129] Step S510: setting the operation type, the table name to be queried and the field to be queried selected in sequence in this group as contents of different identification blocks respectively.

[0130] The logo block is a content block used to contain content.

[0131] The identification block at least includes content. Of course, the identification block may also include symbols.

[0132] For example, "[Sales Table:]" indicates the identification block corresponding to the table name to be queried, and "Sales Table" is the table name to be queried. Another example is "{Month}" indicates the identification block corresponding to the field to be queried, and "Month" is the field to be queried.

[0133] Step S520, sequentially connect the identification blocks corresponding to the operation type, the table name to be queried and the field to be queried respectively, and encapsulate the sequentially connected identification blocks in the statement block corresponding to the operation type of this group to obtain the statement block corresponding to this group.

[0134] The statement block is used to contain a group of sequentially selected operation types, table names to be queried, and identification blocks corresponding to the fields to be queried; wherein, in the statement block, each identification block is arranged according to the selection order of the operation type, table name to be queried, and field to be queried.

[0135] For example: the statement block is "Select [employee table:]{id, name, customer age}"; where "Select" is the identification block corresponding to the operation type, "[employee table:]" is the identification block corresponding to the table name to be queried, and "{id, name, customer age}" is the identification block corresponding to the field to be queried.

[0136] Step S530: Connect the statement blocks corresponding to each group according to the selection order of each group to form the original query statement.

[0137] When connecting the statement blocks corresponding to each group, the operation type corresponding to each group can be determined, and the statement blocks corresponding to each group are sorted and connected according to the preset operation type order to form the original query statement. Among them, the operation type order is SELECT, FROM, JOIN, WHERE and GROUP BY. The operation type corresponding to each group refers to the first selected operation type in the group.

[0138] Through the embodiments of the present application, the original query statement can be abstracted into a modular block object. The core attributes of the block object include: type, content, position and relationship. The type of the identification block is the parameter corresponding to the identification block (operation type, table name to be queried and field to be queried), the content is the parameter in the identification block, the position is the order in which the parameters are selected, and the relationship is the relationship between each identification block. The type of the statement block is the operation type corresponding to the statement block, the content is the identification blocks in the statement block, the position is the order of the statement block in each statement block, and then a serialized index can be formed. The relationship is the logical relationship between the statement block and other statement blocks, for example: the association relationship between the statement block and other statement blocks.

[0139] For example, the original query statement A is:

[0140] Select [employee table:] {id, name, customer age}

[0141] Connection [Sales table:] {month, total sales, employee id}

[0142] Relate [employee table:]{id}=[sales table:]{employeeid}

[0143] Condition [employee table:] {id} = 1

[0144] and [Sales Table:]{Month}=1

[0145] or [Sales table:]{month}=2

[0146] Group [employee table:] {id}

[0147] Among them, "select [employee table:]{id, name, customer age}" is a statement block of the selection operation type; "join [sales table:]{month, total sales, employee id}" is a statement block of the join operation type; "associate [employee table:]{id}=[sales table:]{employee id}" is a statement block of the association operation type; "condition [employee table:]{id}=1", "and [sales table:]{month}=1" and "or [sales table:]{month}=2" constitute a statement block of the conditional operation type. In the original query statement, the identification blocks in each row have a sequence, and each statement block also has a sequence.

[0148] In the embodiment of the present application, the original query statement generated, the initial query statement generated by calling the historical query record, and the text query statement generated after optimization can all be displayed in the database language area. In this way, the user can see the evolution process from the original query statement to the initial query statement and then to the text query statement, and can participate in it. For example: adjust the original query statement, the initial query statement, and the text query statement.

[0149] In the embodiment of the present application, after the textual query statement is generated, the textual query statement can be displayed in the database language area. For database professionals and technicians who may need to view native statements, a switch button can be set in the database language area, and the switch button is used to trigger the conversion of the textual query statement into a database query statement and display it. Of course, the original query statement and the initial query statement can also be switched by the switch button.

[0150] For example: Convert the original query statement A above into a database query statement:

[0151] SELECT

[0152] id,name,customer age

[0153] FROM

[0154] Employee Table

[0155] JOIN

[0156] Sales table s ON e.id = s.employeeid

[0157] WHERE

[0158] e.id=1

[0159] AND(s.month=1OR s.month=2)

[0160] GROUP BY

[0161] e.id;

[0162] In the embodiment of the present application, during the process of displaying the textual query statement, the textual query statement can be adjusted, that is, a block operation is performed on the textual query statement. The adjustment of the original query statement and the adjustment of the initial query statement can refer to the adjustment process of the textual query statement.

[0163] Specifically, a preset adjustment triggering event may be detected at each of the identification blocks; for the identification block where the adjustment triggering event is detected, an adjustment operation may be performed on the content of the identification block and the textual query statement may be updated.

[0164] Adjustment trigger events use triggers to adjust the content in the identification block. Adjustment trigger events include but are not limited to mouse operation events, keyboard operation events, and control operation events.

[0165] The types of adjustment trigger events include, but are not limited to, trigger type, add type, delete type, and modify type. Among them, the adjustment trigger event of the trigger type is used to display multiple adjustment items; the types of adjustment items include: add, delete, and modify. Clicking "Add" can trigger the adjustment trigger event of the add type; clicking "Delete" can trigger the adjustment trigger event of the delete type; clicking "Modify" can trigger the adjustment trigger event of the modify type.

[0166] The adjustment trigger event of the add type is used to trigger the content in the corresponding identification block to be added. The adjustment trigger event of the delete type is used to trigger the corresponding identification block to be deleted. The adjustment trigger event of the modify type is used to trigger the content in the corresponding identification block to be modified.

[0167] In the case where the adjustment trigger event corresponds to an add type, if the identification block corresponds to a field to be queried, a preset add input box pops up; the field to be queried received in the add input box is added to the identification block. Furthermore, if the identification block corresponds to an operation type and a table name to be queried, it is necessary to add a group of operation types corresponding to the operation type buttons selected in sequence, the table name to be queried and the field to be queried to achieve the above.

[0168] In the case where the adjustment trigger event corresponds to a deletion type, if the identification block corresponds to a field to be queried and the identification block includes multiple fields to be queried, the selected field to be queried is deleted; otherwise, the statement block where the identification block is located is deleted.

[0169] Furthermore, if the identification block corresponds to a field to be queried and the identification block includes multiple fields to be queried, deleting one of the fields to be queried will not have adverse effects on the current database query, so the selected field to be queried can be deleted. For example: right-click the field to be queried to be deleted, select the delete option in the pop-up options, and then trigger the adjustment trigger event of the delete type to perform the delete operation on the field to be queried.

[0170] Furthermore, if the identification block corresponds to the table name or operation type to be queried, or the identification block corresponds to the field to be queried and the identification block includes a field to be queried, then the deletion operation will affect the current database query, so the entire statement block is directly deleted to avoid the adverse effects of deleting part of it on the current database query.

[0171] Furthermore, if the first statement block is deleted, then after the first statement block is deleted, the operation type corresponding to the second statement block is adjusted to the operation type corresponding to the first statement block. Generally speaking, the first statement block is a statement block corresponding to the selection operation type, that is, the database table name corresponding to the main database table is selected. If the first statement block is deleted, the current operation type in the second statement block needs to be adjusted to the selection operation type so that the updated first statement block still corresponds to the selection operation type.

[0172] In the case where the adjustment triggering event corresponds to a modification type, a preset modification input box may be popped up, and the original content in the identification block may be replaced with the valid content received in the modification input box.

[0173] Valid content refers to content that is allowed to be modified. For example, if the operation type in the first statement block is changed to a conditional operation type, the modified content is determined to be invalid content.

[0174] Specifically, a preset movement triggering event may be detected at each of the statement blocks; a movement operation may be performed on the statement block where the movement triggering event is detected, and the textual query statement may be updated.

[0175] The types of movement trigger events include at least a start point trigger event and an end point trigger event.

[0176] The statement block is moved from the position corresponding to the starting point triggering event to the position corresponding to the ending point triggering event.

[0177] For example, by listening to mouse operation events: mousedown event and mousemove event, the initial position of the statement block and the offset of the mouse movement can be obtained. When the user presses the statement block, the mousedown event can be detected to capture the mouse position. When the mouse moves, the mousemove event can be detected to calculate the offset in real time and adjust the CSS style of the statement block. When the mouse is released, the mousedown event can be detected to calculate the new position of the statement block, and then the adjusted position of the statement block can be determined.

[0178] In an embodiment of the present application, each time a statement block is moved, each time an identification block is added, deleted, or modified, the textual query statement needs to be updated. Furthermore, updating the textual query statement includes: dynamically adjusting and splicing each statement block in the order specified by the database standard syntax. Among them, the order of operation types specified in the database standard syntax is: in order from front to back, the operation types corresponding to each statement block are: SELECT, FROM, JOIN, WHERE, and GROUP BY. SELECT indicates a selection operation type. FROM indicates a database table to be retrieved. JOIN indicates a connection operation type. WHERE indicates a conditional operation type. GROUP BY indicates a grouping operation type.

[0179] In an embodiment of the present application, after a textual query statement is generated, the textual query statement can be executed. For example, clicking an execution button set in the database language area triggers the execution of the textual query statement. When executing the textual query statement, the textual query statement is first converted into a database query statement, and then the database query statement is executed. For example, converting the textual query statement into an SQL statement.

[0180] In the embodiment of the present application, after executing the textual query statement, the database query result corresponding to the textual query statement can be obtained; the database query result corresponding to the textual query statement can be displayed in the result display area.

[0181] Specifically, since after each execution of a database query, the textual query statement used in the database query and the obtained database query result can be selected and stored, in order to improve query performance and avoid repeatedly executing the same textual query statement in the database, when it is determined that the textual query statement used in this database query is the same as the stored textual query statement, executing the textual query statement includes: obtaining the database query result corresponding to the stored textual query statement. This method of directly returning the database query result corresponding to the stored textual query statement can effectively reduce the query burden of the database.

[0182] In the embodiment of the present application, the database query result can be analyzed in a preset result analysis area.

[0183] Specifically, in a preset result analysis area, input analysis information is detected; wherein the analysis information includes analysis type and / or modeling information; in the result analysis area, the database query result is displayed according to the analysis information and interactive operations are performed on the database query result.

[0184] Analysis types include but are not limited to: chart types, statistical indicators. Chart types include but are not limited to: bar charts, pie charts, scatter charts and pivot tables. Statistical indicators include but are not limited to: mean value, standard deviation, maximum value and minimum value.

[0185] Modeling information includes but is not limited to: key-value pairs. Based on the input key-value pairs, the analysis objects corresponding to the dimensions and the analysis objects corresponding to the measures can be determined. For example: the dimensions are time, region, and product category, and the measure is sales; the analysis object of time is "month", the analysis object of region is "East China", the analysis object of product category is "electronic products", and the analysis object of "sales" is a specific value, thereby forming a multidimensional data set. The database query results can be loaded into the multidimensional data combination according to the dimensions and measures, so that users can see the specific values ​​of the measures under each specific dimension.

[0186] In the process of displaying the database query results according to the analysis information, operations can be performed on the displayed database query results, for example, adjusting the data to be displayed in the pivot table, adjusting the analysis type of the database query results, etc.

[0187] In an embodiment of the present application, after obtaining the database query result corresponding to the textual query statement, the operation type corresponding to the operation type button selected in sequence, the table name to be queried, and the field to be queried can be triggered to record the textual query statement generated, the data query statement corresponding to the textual query statement, and the obtained database query result to form a historical query record corresponding to this database query; in the result set storage area, a label is set for the historical query record so that a filtering condition can be subsequently constructed based on the label.

[0188] Specifically, after each database query, the query record of this database query trip can be stored as a historical query record as needed. The query record formed by this database query can be submitted using the git command; version information is generated for the query record. Version information includes but is not limited to: the operation type corresponding to the operation type button selected in sequence, the name of the table to be queried, the field to be queried, the text query statement generated, the data query statement corresponding to the text query statement, the database query result obtained, and the execution time. Set a label for the query record. Store the label set for the query record in the metadata of the query record. Further, the label can be a custom label (for example: the label is set to "monthly report") or a label selected from the preset optional labels. A label setting box can be set in the result set storage area, and the user can enter the required custom set label in the label setting box.

[0189] Furthermore, historical query information can be stored in a preset storage database. The types of storage databases include, but are not limited to, NoSQL databases (such as MongoDB) or relational databases (such as PostgreSQL). The data stored in the storage database can be organized according to timestamps and other metadata, supporting full-text search and complex query conditions. The stored data can be automatically backed up regularly using backup tools (such as mongodump), and the backup files can be stored in a preset cloud storage service (such as AWS S3) to ensure data security and integrity.

[0190] The embodiment of the present application adopts an intuitive dial-type interface design, which reduces the difficulty of user operation. Compared with the traditional technology that usually requires users to directly write SQL statements and has high requirements on user skills, the database query method of the embodiment of the present application can construct textual query statements through simple selection. The tool is simple and easy to use, and the constructed query statements are highly readable. The embodiment of the present application supports NLP (Natural Language Processing) technology, which can fuzzy match database table names and database fields, effectively narrowing the scope of database table names and database fields. Compared with the traditional technology that provides a drop-down menu, allowing users to find the required database table name and database field in the drop-down menu, the embodiment of the present application is faster. The embodiment of the present application introduces an intelligent recommendation mechanism, which automatically recommends commonly used query conditions based on the user's historical query information, thereby improving query efficiency.

[0191] The present application also provides a database query device. Figure 6 , which is a structural diagram of a database query device according to an embodiment of the present application.

[0192] The database query device comprises:

[0193] The connection module 610 is used to connect to a preset database.

[0194] The selection module 620 is used to display multiple operation type buttons in a preset operation type selection area and detect the selected operation type button; display multiple database table names in a preset first variable selection area and determine the selected database table name as the table name to be queried; and display multiple database fields corresponding to the table name to be queried in a preset second variable selection area and determine the selected database field as the field to be queried.

[0195] The generating module 630 is used to generate a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the name of the table to be queried and the field to be queried, and display the textual query statement in a preset database language area.

[0196] The query module 640 is used to execute the textual query statement and display the database query result corresponding to the textual query statement in a preset result display area.

[0197] The functions of the device described in the embodiment of the present application have been described in the above method embodiment. Therefore, for any details not provided in the description of this embodiment, please refer to the relevant descriptions in the above embodiment and will not be repeated here.

[0198] The present application also provides a database query device, such as Figure 7 , which is a structural diagram of a database query device according to an embodiment of the present application.

[0199] The database query device includes: a processor 710, a communication interface 720, a memory 730 and a communication bus 740. The processor 710, the communication interface 720 and the memory 730 communicate with each other via the communication bus 740.

[0200] The memory 730 is used to store computer programs.

[0201] In one embodiment of the present application, the processor 710, when executing the program stored in the memory 730, implements the database query method provided by any of the aforementioned method embodiments, including: connecting to a preset database; displaying multiple operation type buttons in a preset operation type selection area and detecting the selected operation type button; displaying multiple database table names in a preset first variable selection area and determining the selected database table name as the table name to be queried; displaying multiple database fields corresponding to the table name to be queried in a preset second variable selection area and determining the selected database field as the field to be queried; generating a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, and displaying the textual query statement in a preset database language area; executing the textual query statement and displaying the database query result corresponding to the textual query statement in a preset result display area.

[0202] Among them, the displaying of multiple database table names in a preset first variable selection area and determining the selected database table name as the table name to be queried includes: determining the query frequencies corresponding to the multiple database table names respectively according to the stored historical query information; in a preset selection suggestion area, displaying a preset number of the database table names in descending order of query frequency; and using the database table name selected in the selection suggestion area as the table name to be queried; or, in the first variable selection area, obtaining text input information; among the multiple database table names displayed, retaining the database table name that matches the text input information; and using the selected database table name among the database table names that match the text input information as the table name to be queried.

[0203] Among them, the generating of a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the name of the table to be queried and the field to be queried includes: generating an initial query statement according to the operation type corresponding to the operation type button selected in sequence, the name of the table to be queried and the field to be queried; generating execution plan information corresponding to the initial query statement; extracting operation information corresponding to the initial query statement from the execution plan information; determining execution cost information corresponding to the execution plan information according to the operation information corresponding to the initial query statement; adjusting the initial query statement according to the execution cost information to obtain the textual query statement.

[0204] Among them, the initial query statement is generated according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, including: generating an original query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried; receiving a filtering condition in a preset historical result calling area; displaying at least one historical query record in the historical query information that meets the filtering condition in the historical result calling area; wherein the historical query record records the operation type, database table, database field, textual query statement and database query result corresponding to at least one database query; determining the historical query record selected in the historical result calling area; connecting the textual query statement in the selected historical query record to the original query statement to form the initial query statement.

[0205] Among them, the generating of the original query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried includes: for each group of the operation type, the table name to be queried and the field to be queried selected in sequence, performing the following operations: setting the operation type, the table name to be queried and the field to be queried selected in sequence in this group as the contents of different identification blocks respectively; sequentially connecting the identification blocks corresponding to the operation type, the table name to be queried and the field to be queried respectively, and encapsulating each of the sequentially connected identification blocks in the statement block corresponding to the operation type in this group to obtain the statement block corresponding to this group; connecting the statement blocks corresponding to each group according to the selection order of each group to form the original query statement.

[0206] Among them, in the process of displaying the textual query statement in the preset database language area, it also includes: at each of the identification blocks, detecting a preset adjustment trigger event; for the identification block where the adjustment trigger event is detected, performing an adjustment operation on the content of the identification block and updating the textual query statement; and, at each of the statement blocks, detecting a preset move trigger event; for the statement block where the move trigger event is detected, performing a move operation and updating the textual query statement.

[0207] Among them, in the process of displaying the database query results corresponding to the textual query statement in the preset result display area, it also includes: in the preset result analysis area, detecting the input analysis information; wherein the analysis information includes analysis type and / or modeling information; in the result analysis area, according to the analysis information, displaying the database query results and performing interactive operations on the database query results.

[0208] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the database query method provided in any of the above method embodiments are implemented. Since the database query method has been described in detail above, for any details not fully described in the description of this embodiment, please refer to the relevant description in the above embodiments, and no further description will be given here.

[0209] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0210] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0211] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive and therefore specify the presence of stated features, steps, inquiries, elements and / or parts, but do not exclude the presence or addition of one or more other features, steps, inquiries, elements, parts, and / or combinations thereof. The method steps, processes, and inquiries described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0212] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A database query method, characterized in that: include: Connect to the preset database; Displaying a plurality of operation type buttons in a preset operation type selection area and detecting a selected operation type button; Displaying a plurality of database table names in a preset first variable selection area and determining the selected database table name as the table name to be queried; Displaying a plurality of database fields corresponding to the table name to be queried in a preset second variable selection area and determining the selected database field as the field to be queried; Generate a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the name of the table to be queried and the field to be queried, and display the textual query statement in a preset database language area; The textual query statement is executed and a database query result corresponding to the textual query statement is displayed in a preset result display area.

2. The method according to claim 1, characterized in that The step of displaying a plurality of database table names in a preset first variable selection area and determining the selected database table name as the table name to be queried includes: Determine the query frequencies corresponding to the plurality of database table names respectively according to the stored historical query information; display a preset number of the database table names in a preset selection suggestion area in descending order of query frequency; and use the database table name selected in the selection suggestion area as the table name to be queried; or In the first variable selection area, text input information is obtained; among the multiple displayed database table names, the database table names matching the text input information are retained and displayed; and the database table name selected from the database table names matching the text input information is used as the table name to be queried.

3. The method according to claim 1, characterized in that Generating a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried includes: Generate an initial query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried; Generate execution plan information corresponding to the initial query statement; Extracting operation information corresponding to the initial query statement from the execution plan information; Determining execution cost information corresponding to the execution plan information according to the operation information corresponding to the initial query statement; The initial query statement is adjusted according to the execution cost information to obtain the textual query statement.

4. The method according to claim 3, characterized in that The initial query statement is generated according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried, including: Generate an original query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried; In the preset historical result calling area, receive the filtering conditions; In the historical result calling area, at least one historical query record in the historical query information that meets the filtering condition is displayed; wherein the historical query record records at least one operation type, database table, database field, textual query statement and database query result corresponding to a database query; Determine the selected historical query record in the historical result calling area; The textual query statement in the selected historical query record is connected to the original query statement to form the initial query statement.

5. The method according to claim 4, characterized in that The generating of the original query statement according to the operation type corresponding to the operation type button selected in sequence, the table name to be queried and the field to be queried includes: For each group of the operation type, the table name to be queried, and the field to be queried selected in sequence, perform the following operations: The operation type, the table name to be queried and the field to be queried selected in sequence in this group are respectively set as contents of different identification blocks; Sequentially connect the identification blocks corresponding to the operation type, the table name to be queried, and the field to be queried, respectively, and encapsulate the sequentially connected identification blocks in the statement block corresponding to the operation type of this group to obtain the statement block corresponding to this group; According to the selection order of each group, the statement blocks corresponding to each group are connected to form the original query statement.

6. The method according to claim 5, characterized in that The process of displaying the textual query statement in the preset database language area also includes: At each of the identified blocks, a preset adjustment trigger event is detected; for the identified block where the adjustment trigger event is detected, an adjustment operation is performed on the content of the identified block and the textual query statement is updated; and, At each of the statement blocks, a preset movement trigger event is detected; a movement operation is performed on the statement block where the movement trigger event is detected, and the textual query statement is updated.

7. The method according to claim 1, characterized in that The process of displaying the database query result corresponding to the textual query statement in the preset result display area also includes: In a preset result analysis area, input analysis information is detected; wherein the analysis information includes analysis type and / or modeling information; In the result analysis area, the database query result is displayed according to the analysis information and an interactive operation is performed on the database query result.

8. A database query device, characterized in that: include: A connection module is used to connect to a preset database; A selection module, used to display a plurality of operation type buttons in a preset operation type selection area and detect a selected operation type button; Displaying a plurality of database table names in a preset first variable selection area and determining the selected database table name as the table name to be queried; And, displaying a plurality of database fields corresponding to the table name to be queried in a preset second variable selection area and determining the selected database field as the field to be queried; A generating module, configured to generate a textual query statement according to the operation type corresponding to the operation type button selected in sequence, the name of the table to be queried and the field to be queried, and to display the textual query statement in a preset database language area; The query module is used to execute the textual query statement and display the database query result corresponding to the textual query statement in a preset result display area.

9. A database query device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to: execute a database query program stored in the memory to implement the database query method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed to implement the database query method according to any one of claims 1 to 7.