Table of Contents
SQL Editor - Autocomplete
While you type in SQL Editor, the autocomplete feature will help you type your SQL commands faster.
As only you have type the first letter you can get an autocomplete menu with suggestions.
For this Valentina Studio collects different information. For example:
- list of identifiers from your database (e.g. Table, Field names, etc)
- list of keywords from DBMS
- list of built-in functions from DBMS
You can move in the menu by UP/DOWN arrow buttons. You can press ENTER to use the current item of the menu as the final choice. The menu will be closed and the item will be typed. The same you can do by mouse-click on an item.
Press ESC if you want to close the menu without any choice. You can force to show the menu pressing CTRL/CMD + '.' shortcut for the command “SQL → Complete Word”.
Some items of the menu can show a tooltip with useful information.
You can tune how auto-completion works in the Preferences Dialog
This is the original style of autocomplete, which worked in Valentina Studio for years.
When you type letters, they are used to find strings in the prepared lists using StartWith search. Typed chars are shown in the menu in yellow color.
Additionally, the algorithm tries to find a group of strings with the same “future prefix” using the currently selected item.
If such “future prefix” is found, it is highlighted in the menu by PINK color and if you press TAB-button on the keyboard this “future prefix” will be typed for you.
On the picture, you can see that “admintools_” is marked as a future prefix. On TAB it will be added to the typed string, so will be “jos3_admintools_”.
This style of autocomplete was added into v10.5 (Sept 2020).
When you type letters, they are used to find strings in the prepared lists using the RegEx search, which is able to find that letters also inside of strings. Notice that the StartWith search is the special case of the RegEx search.
RegEx search can be more comfortable if many names in a database use common prefixes, like on the picture above: “jos3_”, “admintools_”. You can skip these prefixes and start to type a significant part.
Notice, that if you use this style of autocompletion, then there is no feature “future prefix”, because it has no sense.
Special SQL Lists
This list is shown in the auto-complete menu when
- SQL Analyzer recognizes a SELECT command
- and SELECT expression has only the first item typed
- FROM clause has the name of a Table.
If you choose this item then the list of all fields of the table mentioned in the FROM clause is inserted into SQL Editor.
The same works for the INSERT command.
Notice, that you can start type any character to see this list on the menu. A good tip is to use '*', then you will not see other identifiers in the menu.
For the INSERT command in the VALUES clause a developer may want to use a list of bind-value. If the command has many fields then typing such a list is annoying enough task.
Autocomplete will be able to help with this. Type any character when you are inside of the parenthesis of VALUE to see that lists on the menu.
You can copy-paste such a query into your code in some programming language.
Also, you can test this query with some values in Valentina Studio. For this enter values in the right-side panel Parameters.