MySQL Shell supports autocompletion of text preceding the cursor
by pressing the Tab key. The
Section 3.1, “MySQL Shell Commands” can be autocompleted in any
of the language modes. For example typing
\con and pressing the
Tab key autocompletes to
\connect. Autocompletion is available for
current Section 5.1, “Active Language”.
Autocompletion supports the following text objects:
In SQL mode - autocompletion is aware of schema names, table names, column names of the current active schema.
global object names such as
mysqlx, and so on.
members of global objects such as
dba.configureLocalInstance(), and so on.
global user defined variables
chained object property references such as
chained X DevAPI method calls such as
By default autocompletion is enabled, to change this behavior see Configuring Autocompletion.
Once you activate autocompletion, if the text preceding the cursor
has exactly one possible match, the text is automatically
completed. If autocompletion finds multiple possible matches, it
beeps or flashes the terminal. If the
is pressed again, a list of the possible completions is displayed.
If no match is found then no autocompletion happens.
When MySQL Shell is in SQL mode, autocompletion tries to complete any word with all possible completions that match. In SQL mode the following can be autocompleted:
SQL keywords - List of known SQL keywords. Matching is case-insensitive.
Table names - If there is an active schema and database name caching is not disabled, all the tables of the active schema are used as possible completions.
As a special exception, if a backtick is found, only table names
are considered for completion. In SQL mode, autocompletion is
not context aware, meaning there is no filtering of completions
based on the SQL grammar. In other words, autocompleting
SELECT, but it could also include
a table called selfies.
print(db.user.select().where("user in ('foo', 'bar')").e
Pressing the Tab key would cause autocompletion
to try to complete the text
db.user.select().where().e but this
invalid code yields undefined behavior. Any whitespace,
including newlines, between tokens separated by a
. is ignored.
By default the autocompletion engine is enabled. This section
explains how to disable autocompletion and how to use the
\rehash MySQL Shell command. Autocompletion
uses a cache of database name objects that MySQL Shell is
aware of. When autocompletion is enabled, this name cache is
automatically updated. For example whenever you load a schema,
the autocompletion engine updates the name cache based on the
text objects found in the schema, so that you can autocomplete
table names and so on.
To disable this behavior you can:
Start MySQL Shell with the
devapi.dbObjectHandleskeys of the
shell.optionsto disable the autocompletion while MySQL Shell is running.
When the autocompletion name cache is disabled, you can manually
update the text objects autocompletion is aware of by issuing
\rehash. This forces a reload of the name
cache based on the current active schema.
To disable autocompletion while MySQL Shell is running use the
autocomplete.nameCache: booleantoggles autocompletion name caching for use by SQL.
devapi.dbObjectHandles: booleantoggles autocompletion name caching for use by the X DevAPI
dbobject, for example
Both keys are set to
true by default, and set
false if the
--no-name-cache command option
is used. To change the autocompletion name caching for SQL while
MySQL Shell is running, issue:
\rehash command to update the name
Again you can use the
\rehash command to
update the name cache manually.