A method and apparatus for correcting spelling mistakes in database statements

The method addresses the lack of pre-prompting in non-relational databases by suggesting corrections based on table name similarity, ensuring accurate SQL statement error correction in distributed databases.

CN111435406BActive Publication Date: 2025-07-15BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910031911.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-01-14
Publication Date
2025-07-15
Estimated Expiration
2039-01-14

AI Technical Summary

Technical Problem

Non-relational distributed databases lack pre-prompt error correction function during SQL development, and existing associative prompts based on alphabetical order of table names or field names can easily lead to resulting errors.

Method used

Correct spelling errors by obtaining the keywords in the target statement, calculating its comprehensive similarity to the table names in the database metadata, and sorting the similarity table names in the prompt page according to the similarity, to correct spelling errors.

Benefits of technology

It realizes accurate correction of sentence spelling errors in non-relational distributed databases, avoids resultant errors caused by alphabetical associative hints, and improves the accuracy of the development process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111435406B_ABST
    Figure CN111435406B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for correcting spelling errors in database statements, and relates to the field of computer technology. A specific implementation of the method includes: obtaining the table name after the first keyword in the target statement; determining the comprehensive similarity between the table name after the first keyword and the table name in the database metadata; displaying the table name in the metadata in the prompt page of the table name after the first keyword in the order of the comprehensive similarity from high to low, so as to correct the spelling error of the target statement. Because this implementation adopts the technical means of associative prompting based on the similarity of the table name, it overcomes the technical problem that non-relational distributed databases do not have a mature pre-prompt function, and at the same time, there will be no result errors caused by associative prompting based on the alphabetical order of the table name or field name like the relational database, thereby achieving a more accurate error correction effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to a method and device for correcting spelling errors in database statements. Background Art

[0002] Currently, distributed databases have gradually replaced traditional relational databases. The most typical distributed database is the Hive database. In terms of statement error correction, the development tools of relational databases can provide good hints for table names or field names during the development process. After typing a dot after the input database name or table name, the query analyzer will prompt all the tables under the database name and all the fields under the table. This pre-hint function can, to a certain extent, avoid syntax errors caused by spelling mistakes. However, when developing statements on a distributed database and encountering a syntax error, error correction is not as convenient as that of a relational database, and it can only be solved after an error is reported during compilation.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] 1. Currently, this kind of pre-hint function only appears in relational databases, and there is no mature one for non-relational distributed databases yet.

[0005] 2. Although the pre-hint function of relational databases can ultimately avoid spelling mistakes of words, there are many similar words, and the hints are based on the alphabetical order of table names / field names for associative hints. If the developer has a vague memory of the table name or field name and cannot accurately remember the order of each letter, then the developer may ultimately choose the wrong table name or field name, resulting in an error that is not a spelling mistake but a consequential error, and the query result is not the actual data required. Summary of the Invention

[0006] In view of this, an embodiment of the present invention provides a method and device for correcting spelling errors in database statements, which can provide a method for pre-hinting and correcting statements during SQL development for non-relational distributed databases, and at the same time, the situation of consequential errors caused by associative hints based on the alphabetical order of table names or field names in relational databases will not occur.

[0007] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for correcting spelling errors in database statements is provided, including: obtaining the table name after the first keyword in the target statement; determining the comprehensive similarity between the table name after the first keyword and the table names in the database metadata; and displaying the table names in the metadata in the hint page of the table name after the first keyword in descending order of the comprehensive similarity to correct the spelling error of the target statement.

[0008] Optionally, determining the comprehensive similarity between the table name after the first keyword and the table names in the database metadata includes: determining the letters and their numbers included in the table name after the first keyword and the letters and their numbers included in the table names in the metadata; determining the letter type similarity between the table name after the first keyword and the table names in the metadata according to the letters and their numbers included in the table name, and sorting the table names in the metadata in descending order of the letter type similarity to obtain a first sequence; determining the letter order similarity between the table name after the first keyword and the table names in the metadata according to the order of the letters in the table name, and sorting the table names in the metadata in descending order of the letter order similarity to obtain a second sequence; performing a weighted summation process on the table names in the metadata in the first sequence and the second sequence, and using the obtained sum value as the comprehensive similarity between the table name after the first keyword and the table names in the database metadata.

[0009] Optionally, determining the letters and their numbers included in the table name after the first keyword and the letters and their numbers included in the table names in the metadata includes: determining the letters and their numbers included in the table name after the first keyword, and using this letter as a screening letter; screening out the table names containing any of the screening letters from the table names in the metadata, and determining the letters and their numbers included in the screened-out table names; using the screened-out table names as the new table names in the metadata.

[0010] Optionally, after obtaining the table name after the first keyword in the target statement, it further includes: determining whether the table name after the first keyword is the same as the table names in the metadata. If they are the same, then: obtaining the field name after the second keyword in the target statement; determining, from the database metadata, the field name in the table corresponding to the table name after the first keyword, and using this field name as the first field name to be matched; determining the overall similarity between the field name after the second keyword and the first field name to be matched; displaying the first field name to be matched in the prompt page of the field name after the second keyword in descending order of the overall similarity to correct the spelling error of the field name in the target statement.

[0011] Optionally, after displaying the table names in the metadata in the prompt page of the table name after the first keyword in descending order of the comprehensive similarity to correct the spelling error of the target statement, it further includes: selecting any table name from the table names in the metadata displayed in the prompt page as the target table name; obtaining the field name after the second keyword in the target statement; determining, from the database metadata, the field name in the table corresponding to the target table name, and using this field name as the second field name to be matched;

[0012] Determining the overall similarity between the field name after the second keyword and the second field name to be matched;

[0013] In the order of the overall similarity from high to low, display the second field name to be matched in the prompt page of the field name after the second keyword, so as to correct the spelling error of the field name in the target statement.

[0014] Optionally, obtaining the table name after the first keyword in the target statement includes: determining whether the number of the first keywords in the target statement is 1; if so, obtaining the table name after the first keyword in the target statement; if not, ending the error correction process of the target statement.

[0015] According to another aspect of the embodiments of the present invention, there is provided an apparatus for correcting spelling errors in database statements, including: an acquisition module, configured to: acquire the table name after the first keyword in the target statement; a similarity matching module, configured to: determine the comprehensive similarity between the table name after the first keyword and the table names in the database metadata; a result output module, configured to: display the table names in the metadata in the prompt page of the table name after the first keyword in the order of the comprehensive similarity from high to low, so as to correct the spelling errors in the target statement.

[0016] Optionally, the similarity matching module is further configured to: determine the letters included in the table name after the first keyword and their numbers and the letters included in the table names in the metadata and their numbers; determine the letter type similarity between the table name after the first keyword and the table names in the metadata according to the letters included in the table name and their numbers, and sort the table names in the metadata in the order of the letter type similarity from high to low to obtain a first sequence; determine the letter order similarity between the table name after the first keyword and the table names in the metadata according to the order of the letters in the table name, and sort the table names in the metadata in the order of the letter order similarity from high to low to obtain a second sequence; perform a weighted summation process on the table names in the metadata in the first sequence and the second sequence, and use the obtained sum value as the comprehensive similarity between the table name after the first keyword and the table names in the database metadata.

[0017] Optionally, the similarity matching module is further configured to: determine the letters included in the table name after the first keyword and their numbers, and use the letter as a screening letter; screen out the table names containing any of the screening letters from the table names in the metadata, and determine the letters included in the screened-out table names and their numbers; use the screened-out table names as the new table names in the metadata.

[0018] Optionally, the device further includes a word judgment module, configured to: judge whether the table name after the first keyword is the same as the table name in the metadata; if so, then: obtain the field name after the second keyword in the target statement; determine from the database metadata the field name in the table corresponding to the table name after the first keyword, and use this field name as the first field name to be matched; determine the overall similarity between the field name after the second keyword and the first field name to be matched; display the first field name to be matched in the prompt page of the field name after the second keyword in descending order of the overall similarity, so as to correct the spelling error of the field name in the target statement.

[0019] Optionally, the device further includes a field name correction module, configured to: select any table name from the table names in the metadata displayed in the prompt page as the target table name; obtain the field name after the second keyword in the target statement; determine from the database metadata the field name in the table corresponding to the target table name, and use this field name as the second field name to be matched; determine the overall similarity between the field name after the second keyword and the second field name to be matched; display the second field name to be matched in the prompt page of the field name after the second keyword in descending order of the overall similarity, so as to correct the spelling error of the field name in the target statement.

[0020] Optionally, the obtaining module is further configured to: judge whether the number of the first keywords in the target statement is 1; if so, then obtain the table name after the first keyword in the target statement; if not, then end the error correction process of the target statement.

[0021] According to another aspect of the embodiments of the present invention, there is provided an electronic device, including: one or more processors; a storage device for storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement a method for correcting spelling errors of database statements as provided in the embodiments of the present invention.

[0022] According to another aspect of the embodiments of the present invention, there is provided a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, it implements a method for correcting spelling errors of database statements as provided in the embodiments of the present invention.

[0023] An embodiment of the above invention has the following advantages or beneficial effects: because a technical means of associative prompting based on the similarity of table names is adopted, the technical problem that non-relational distributed databases do not have a mature pre-prompt function is overcome, and a method for pre-prompting and correcting statements during SQL development is provided for non-relational distributed databases. At the same time, there will be no result errors caused by associative prompting based on the alphabetical order of table names or field names like relational databases, thereby achieving a more accurate error correction effect.

[0024] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0026] Figure 1 is a schematic diagram of the basic process of a method for correcting spelling errors in database statements according to an embodiment of the present invention;

[0027] Figure 2 It is a flow chart of a preferred embodiment of obtaining the table name after the first keyword and then performing table name determination;

[0028] Figure 3 It is a flow chart of a preferred embodiment of determining the comprehensive similarity between the table name after the first keyword and the table name in the database metadata;

[0029] Figure 4 It is a flowchart diagram of a preferred embodiment of obtaining the table name after the first keyword in the target sentence;

[0030] Figure 5 is a schematic diagram of a preferred process of a method for correcting spelling errors in database statements according to an embodiment of the present invention;

[0031] Figure 6 is a schematic diagram of basic modules of an apparatus for correcting spelling errors of database statements according to an embodiment of the present invention;

[0032] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0033] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0035] Figure 1 FIG. 1 is a schematic diagram of the basic process of a method for correcting spelling errors in database statements according to an embodiment of the present invention. Figure 1 As shown, an embodiment of the present invention provides a method for correcting spelling errors in database statements, comprising:

[0036] Step S101. Obtain the table name after the first keyword in the target sentence;

[0037] Step S102: Determine the comprehensive similarity between the table name after the first keyword and the table name in the database metadata;

[0038] Step S103: Display the table name in the metadata in a prompt page of the table name after the first keyword in the order of the comprehensive similarity from high to low, so as to correct the spelling error of the target sentence.

[0039] Keywords refer to fixed and unique words in SQL syntax, which are mainly used for syntax analysis. Keywords include but are not limited to select, from, and where, but these three are commonly used keywords in query functions. Metadata is data of data, which exists in the database system. It will be configured when the database is built. If there is no metadata, the database cannot be used. Hive metadata contains some basic elements of the table, such as the library name, table name, field name, field type, data storage location, etc. of the hive table.

[0040] The embodiment of the present invention adopts a technical means for providing associative prompts based on the similarity of table names, thereby overcoming the technical problem that non-relational distributed databases do not have a mature pre-prompt function. It provides a method for providing pre-prompt error correction for statements during SQL development for non-relational distributed databases, while avoiding the situation in which result errors occur due to associative prompts based on the alphabetical order of table names or field names in relational databases, thereby achieving a more accurate error correction effect.

[0041] In step S102 of the embodiment of the present invention, determining the comprehensive similarity between the table name after the first keyword and the table name in the database metadata includes: determining the letters and their numbers included in the table name after the first keyword and the letters and their numbers included in the table name in the metadata; determining the letter type similarity between the table name after the first keyword and the table name in the metadata according to the letters and their numbers included in the table name, and sorting the table names in the metadata in descending order of the letter type similarity to obtain a first sequence; determining the letter order similarity between the table name after the first keyword and the table name in the metadata according to the order of the letters in the table name, and sorting the table names in the metadata in descending order of the letter order similarity to obtain a second sequence; performing a weighted summation process on the table names in the metadata in the first sequence and the second sequence, and using the obtained sum value as the comprehensive similarity between the table name after the first keyword and the table name in the database metadata.

[0042] Based on the above embodiment, determining the letters and their numbers included in the table name after the first keyword and the letters and their numbers included in the table name in the metadata includes: determining the letters and their numbers included in the table name after the first keyword, and using this letter as a screening letter; screening out the table names containing any of the screening letters from the table names in the metadata, and determining the letters and their numbers included in the screened-out table names; using the screened-out table names as the new table names in the metadata.

[0043] Determining the letter type similarity between the table name after the first keyword and the new table name in the metadata according to the letters and their numbers included in the table name, and sorting the new table names in the metadata in descending order of the letter type similarity to obtain a first sequence; determining the letter order similarity between the table name after the first keyword and the new table name in the metadata according to the order of the letters in the table name, and sorting the new table names in the metadata in descending order of the letter order similarity to obtain a second sequence; performing a weighted summation process on the new table names in the metadata in the first sequence and the second sequence, and using the obtained sum value as the comprehensive similarity between the table name after the first keyword and the table name in the database metadata.

[0044] In an embodiment of the present invention, after obtaining the table name following the first keyword in the target statement in step S101, the following steps are further included: determining whether the table name following the first keyword is the same as the table name in the metadata; if they are the same, it indicates that the table name following the first keyword is correct and no error correction is required, and then error correction for the field names under this table is to be performed, specifically including: obtaining the field name following the second keyword in the target statement; determining, from the database metadata, the field name in the table corresponding to the table name following the first keyword, and using this field name as the first field name to be matched; determining the overall similarity between the field name following the second keyword and the first field name to be matched; and displaying the first field name to be matched in the prompt page of the field name following the second keyword in descending order of the overall similarity to correct the spelling error of the field name in the target statement. If they are not the same, it indicates that the table name following the first keyword is incorrect, and error correction processing for the table name following the first keyword needs to be performed according to the foregoing embodiments. Among them, the logic for determining the overall similarity between the field name following the second keyword and the second field name to be matched is the same as the logic for determining the comprehensive similarity of the table name, which can be understood by those skilled in the art and will not be elaborated here.

[0045] Specifically, an example of error correction for the table name and field name in the target statement is provided:

[0046] 1) Figure 2 It is a flowchart of a preferred embodiment for table name judgment after obtaining the table name following the first keyword, as Figure 2 shown, obtaining the table name "tableA" following the first keyword "from", and judging whether this table exists in the metadata. If it does not exist, it indicates that the table name "tableA" is incorrect, and step 3) is executed. If it exists, then step 2) is entered.

[0047] 2) Figure 3 It is a schematic flowchart of a preferred embodiment for determining the comprehensive similarity between the table name following the first keyword and the table name in the database metadata, as Figure 3 shown. In the case where the table name is already correct, obtaining the field name from behind the second keywords "select" and "where", and comparing the field names with the corresponding table structure found in the metadata. If it does not exist, it indicates that the field name needs error correction, and step 7) is entered; if it exists, it indicates that the target statement has no error, and the spelling error correction is directly ended, and the statement running log is started to be printed to monitor the execution situation of the statement.

[0048] 3) Count the letters and the number of letters included in the incorrect table name "tableA". These letters can be called screening letters; then match the table names in the metadata that contain any one of the screening letters in the table name, form an array to store these table names, and count the number of letters of each of these table names in the array "tablelist".

[0049] 4) Compare the number of letter types and the number of letters of the screened letters with the table names in the numerical tablelist, select the 20 that are closest in terms of the number of letter types and the number of letters, and give a ranking as the first sequence. This "20" can be adjusted according to the number of tables in each library.

[0050] 5) Compare the 20 selected table names that are closest with the incorrect table name "tableA" in alphabetical order, perform an order similarity match, and give a ranking as the second sequence.

[0051] 6) Combine and rank the above two rankings according to weights of "50%" and "50%" (the specific values of the weights can be adjusted) to obtain a new ranking as the third sequence. Display these 20 possibly correct table names on the prompt page in the order of the third sequence for developers to select.

[0052] 7) The logic for the field name similarity match is similar to that in 3)-6) for the table name similarity match. There is an additional process that requires first finding all the field names in the correct table name (or the table name selected by the developer) from the metadata, and then performing the subsequent matching logic.

[0053] In step S103 of the embodiment of the present invention, after displaying the table names in the metadata in the prompt page of the table name after the first keyword in the order from high to low according to the comprehensive similarity to correct the spelling error of the target statement, it further includes: selecting any table name from the table names in the metadata displayed in the prompt page as the target table name; obtaining the field name after the second keyword in the target statement; determining the field names in the table corresponding to the target table name from the database metadata, and using this field name as the second field name to be matched; determining the overall similarity between the field name after the second keyword and the second field name to be matched; and displaying the second field name to be matched in the prompt page of the field name after the second keyword in the order from high to low according to the overall similarity to correct the spelling error of the field name in the target statement.

[0054] Figure 4 It is a schematic flowchart of a preferred embodiment for obtaining the table name after the first keyword in the target statement. As Figure 4 shown, in step S101 of the embodiment of the present invention, the obtaining the table name after the first keyword in the target statement includes: determining whether the number of first keywords in the target statement is 1; if so, obtaining the table name after the first keyword in the target statement; if not, ending the error correction process of the target statement.

[0055] Figure 5 It is a schematic diagram of a preferred process for correcting the spelling error of a database statement according to an embodiment of the present invention. AsFigure 5 As shown, the processes of all the above embodiments are summarized and will not be elaborated here.

[0056] An embodiment of the present invention provides an apparatus 600 for correcting spelling errors in database statements, including: an acquisition module 601 for acquiring the table name after the first keyword in the target statement; a similarity matching module 602 for determining the comprehensive similarity between the table name after the first keyword and the table names in the database metadata; and a result output module 603 for displaying the table names in the metadata in the hint page of the table name after the first keyword in the order from high to low of the comprehensive similarity to correct the spelling errors of the target statement.

[0057] In an embodiment of the present invention, the similarity matching module is further configured to: determine the letters and their numbers included in the table name after the first keyword and the letters and their numbers included in the table names in the metadata; determine the letter type similarity between the table name after the first keyword and the table names in the metadata according to the letters and their numbers included in the table names, and sort the table names in the metadata in the order from high to low of the letter type similarity to obtain a first sequence; determine the letter order similarity between the table name after the first keyword and the table names in the metadata according to the order of the letters in the table names, and sort the table names in the metadata in the order from high to low of the letter order similarity to obtain a second sequence; perform a weighted summation process on the table names in the metadata in the first sequence and the second sequence, and use the obtained sum value as the comprehensive similarity between the table name after the first keyword and the table names in the database metadata.

[0058] In an embodiment of the present invention, the similarity matching module is further configured to: determine the letters and their numbers included in the table name after the first keyword, and use the letter as a screening letter; screen out the table names containing any of the screening letters from the table names in the metadata, and determine the letters and their numbers included in the screened table names; and use the screened table names as the new table names in the metadata.

[0059] In an embodiment of the present invention, the apparatus further includes a word judgment module for: judging whether the table name after the first keyword is the same as the table names in the metadata. If so, it is configured to: acquire the field name after the second keyword in the target statement; determine, from the database metadata, the field name in the table corresponding to the table name after the first keyword, and use the field name as a first field name to be matched; determine the overall similarity between the field name after the second keyword and the first field name to be matched; and display the first field name to be matched in the hint page of the field name after the second keyword in the order from high to low of the overall similarity to correct the spelling errors of the field name in the target statement.

[0060] In an embodiment of the present invention, the device further includes a field name error correction module, which is configured to: select any table name from the table names in the metadata displayed on the prompt page as the target table name; obtain the field name after the second keyword in the target statement; determine, from the database metadata, the field name in the table corresponding to the target table name, and use this field name as the second field name to be matched; determine the overall similarity between the field name after the second keyword and the second field name to be matched; and display the second field name to be matched on the prompt page of the field name after the second keyword in descending order of the overall similarity to correct the spelling error of the field name in the target statement.

[0061] In an embodiment of the present invention, the obtaining module is further configured to: determine whether the number of the first keywords in the target statement is 1; if so, obtain the table name after the first keyword in the target statement; if not, end the error correction process of the target statement.

[0062] According to the above similarity matching results, the possible correct table names and field names are displayed on the prompt page in the ranking order, so that the scope for developers to correct errors is greatly reduced, and the table names or field names in the statement can be quickly corrected through the output results. The string matching algorithm (i.e., the method for calculating similarity) is used to find the table name and field name that are highly correlated with the incorrect table name or field name, and through this highly correlated matching, the table name and field name that the developer is most likely to need are guessed to the greatest extent.

[0063] Figure 7 An exemplary system architecture 700 is shown that can apply the method for correcting spelling errors of database statements or the device for correcting spelling errors of database statements according to embodiments of the present invention.

[0064] As Figure 7 shown, the system architecture 700 may include terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 is used to provide a medium for communication links between the terminal devices 701, 702, 703 and the server 705. The network 704 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0065] Users can use the terminal devices 701, 702, 703 to interact with the server 705 through the network 704 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 701, 702, 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0066] The terminal devices 701, 702, and 703 can be various electronic devices with a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop computers, desktop computers, and the like.

[0067] The server 705 can be a server that provides various services. For example, it can be a background management server that supports shopping websites browsed by users using the terminal devices 701, 702, and 703. The background management server can analyze and process data such as product information query requests received, and feedback the processing results, such as target push information, to the terminal devices.

[0068] It should be noted that the method for correcting spelling errors in database statements provided by the embodiments of the present invention is generally executed by the server 705. Correspondingly, the device for correcting spelling errors in database statements is generally set in the server 705.

[0069] It should be understood that Figure 7 the numbers of terminal devices, networks, and servers in

[0070] are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, networks, and servers.

[0071] The electronic device of the present invention includes: one or more processors; a storage device for storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement a method for correcting spelling errors in database statements as provided by the embodiments of the present invention.

[0072] The computer-readable medium of the present invention stores a computer program thereon, and when the program is executed by a processor, it implements a method for correcting spelling errors in database statements as provided by the embodiments of the present invention.

[0073] Next, refer to Figure 8 , which shows a schematic structural diagram of a computer system 800 of a terminal device suitable for implementing the embodiments of the present invention. Figure 8 The shown terminal device is merely an example and should not impose any limitation on the functions and usage scope of the embodiments of the present invention.

[0074] As Figure 8As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded into a random access memory (RAM) 803 from a storage section 808. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0075] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive 810 as needed so that a computer program read from it can be installed into the storage section 808 as needed.

[0076] Specifically, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above functions defined in the system of the present invention are executed.

[0077] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium can be any tangible medium that contains or stores a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0078] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram can represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks can occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and the combination of blocks in a block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0079] The modules involved in the embodiments of the present invention can be implemented in software or in hardware. The described modules can also be provided in a processor. For example, it can be described as: a processor includes an acquisition module, a similarity matching module, and a result output module. Among them, the names of these modules do not constitute a limitation to the module itself in some cases. For example, the business unit acquisition module can also be described as "the module for acquiring the table name after the first keyword in the target statement".

[0080] As another aspect, the present invention also provides a computer-readable medium. The computer-readable medium can be included in the device described in the above embodiments; or it can exist alone without being assembled into the device. The above computer-readable medium carries one or more programs. When the one or more programs are executed by the device, the device is caused to include: acquiring the table name after the first keyword in the target statement; determining the comprehensive similarity between the table name after the first keyword and the table names in the database metadata; and displaying the table names in the metadata in the prompt page of the table name after the first keyword in the order from high to low according to the comprehensive similarity to correct the spelling error of the target statement.

[0081] Because the embodiments of the present invention adopt the technical means of associative prompting based on the similarity of table names, the technical problem that non-relational distributed databases do not have a well-developed pre-prompting function is overcome. While providing a method for pre-prompting and correcting statements during SQL development for non-relational distributed databases, it will not occur that, like relational databases, associative prompting is performed based on the alphabetical order of table names or field names, resulting in consequential errors, and thus a more accurate error correction effect is achieved.

[0082] The above specific embodiments do not constitute a limitation to the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for correcting spelling mistakes in database statements, characterized in that, Including: Obtain the table name after the first keyword in the target statement; Determine the comprehensive similarity between the table name after the first keyword and the table names in the database metadata, including: determining the letters and their numbers included in the table name after the first keyword and the letters and their numbers in the table names in the metadata; according to the letters and their numbers included in the table name, determine the letter type similarity between the table name after the first keyword and the table names in the metadata, and sort the table names in the metadata in descending order of the letter type similarity to obtain a first sequence; according to the order of the letters in the table name, determine the letter order similarity between the table name after the first keyword and the table names in the metadata, and sort the table names in the metadata in descending order of the letter order similarity to obtain a second sequence; perform a weighted summation process on the table names in the metadata in the first sequence and the second sequence, and use the obtained sum value as the comprehensive similarity between the table name after the first keyword and the table names in the database metadata; Display the table names in the metadata on the prompt page of the table name after the first keyword in descending order of the comprehensive similarity to correct the spelling error of the target statement.

2. The method according to claim 1, characterized in that, The determination of the letters and their numbers included in the table name after the first keyword and the letters and their numbers in the table names in the metadata includes: Determine the letters and their numbers included in the table name after the first keyword, and use this letter as the screening letter; Screen out the table names containing any of the screening letters from the table names in the metadata, and determine the letters and their numbers included in the screened table names; Use the screened table names as the new table names in the metadata.

3. The method according to claim 1, wherein After obtaining the table name after the first keyword in the target statement, it further includes: Judge whether the table name after the first keyword is the same as the table names in the metadata. If they are the same, then: Obtain the field name after the second keyword in the target statement; Determine, from the database metadata, the field names in the table corresponding to the table name after the first keyword, and use this field name as the first field name to be matched; Determine the overall similarity between the field name after the second keyword and the first field name to be matched; Display the first field name to be matched on the prompt page of the field name after the second keyword in descending order of the overall similarity to correct the spelling error of the field name in the target statement.

4. The method according to claim 1, characterized in that After displaying the table names in the metadata on the prompt page of the table name after the first keyword in descending order of the comprehensive similarity to correct the spelling error of the target statement, it further includes: Select any table name from the table names in the metadata displayed on the prompt page as the target table name; Obtain the field name after the second keyword in the target statement; Determine, from the database metadata, the field names in the table corresponding to the target table name, and use this field name as the second field name to be matched; Determine the overall similarity between the field name after the second keyword and the second field name to be matched; In the order of the overall similarity from high to low, display the second field name to be matched in the prompt page of the field name after the second keyword to correct the spelling error of the field name in the target statement.

5. The method according to claim 1, wherein The obtaining of the table name after the first keyword in the target statement includes: Determine whether the number of the first keywords in the target statement is 1; If so, obtain the table name after the first keyword in the target statement; If not, end the error correction process of the target statement.

6. An apparatus for correcting spelling mistakes in database statements, characterized in that, including: An obtaining module, configured to: obtain the table name after the first keyword in the target statement; A similarity matching module, configured to: determine the comprehensive similarity between the table name after the first keyword and the table name in the database metadata, including: determining the letters and their numbers included in the table name after the first keyword and the letters and their numbers included in the table name in the metadata; according to the letters and their numbers included in the table name, determine the letter type similarity between the table name after the first keyword and the table name in the metadata, and sort the table names in the metadata in the order from high to low according to the letter type similarity to obtain a first sequence; according to the order of the letters in the table name, determine the letter order similarity between the table name after the first keyword and the table name in the metadata, and sort the table names in the metadata in the order from high to low according to the letter order similarity to obtain a second sequence; perform a weighted summation process on the table names in the metadata in the first sequence and the second sequence, and use the obtained sum value as the comprehensive similarity between the table name after the first keyword and the table name in the database metadata; A result output module, configured to: display the table names in the metadata in the prompt page of the table name after the first keyword in the order of the comprehensive similarity from high to low to correct the spelling error of the target statement.

7. An electronic device, characterized in that, including: One or more processors; A storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-5.

8. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Method for checking storage table field name in Sql statement, and computer equipment

    CN108388606A