The SQL query toolbar provides actions that enable you to create and manage queries. The following figure shows the set buttons in the toolbar, located within the SQL query tab.
SQL query tools (from left to right) are:
Open a script file in this editor: Loads content from a saved SQL script into the SQL editor.
Save the script to a file: Enables you to save the current content of the SQL editor to a file.
Execute the selected portion of the script or everything, if there is no selection: Provides a simple way to execute the entire query or a subset of the query.
Execute the statement under the keyboard cursor: Uses the position the keyboard cursor to identify and execute the query.
-
Execute the EXPLAIN command on the statement under the keyboard cursor: Uses the position the keyboard cursor to identify the query and then executes
EXPLAIN
. A result grid tab is also displayed when executing anEXPLAIN
statement.Alternatively, the Visual Explain plan is already available for all executed queries. Select Execution Plan from the results tab to view it.
Stop the query being executed: Halts execution of the currently executing SQL script. The connection to the database server is not restarted and all open transactions remain open.
Toggle whether execution of SQL script should continue after failed statements: If the red “breakpoint” circle is displayed, the script terminates on a statement that fails. If you click the button so that the green arrow is displayed, execution continues past the failed code, possibly generating additional result sets. In either case, any error generated from attempting to execute the faulty statement is recorded in the Output pane. You can also set this behavior from the SQL Execution user preferences panel.
Commit the current transaction: All query tabs in the same connection share the same transactions. To have independent transactions, you must open a new connection.
Rollback the current transaction: All query tabs in the same connection share the same transactions. To have independent transactions, you must open a new connection.
-
Toggle autocommit mode: When enabled, each statement is committed immediately. All query tabs in the same connection share the same transactions. To have independent transactions, you must open a new connection.
Autocommit is enabled by default. To disable the default behavior, see the SQL Execution section of the MySQL Workbench Preferences dialog.
-
Set limit for the number of rows returned by queries: MySQL Workbench automatically adds the
LIMIT
clause with the configured number of rows toSELECT
queries. The default value is 1000.The default value (1000) can be changed from the SQL Execution section of the MySQL Workbench Preferences dialog.
Save current statement or selection to the snippet list: For more information about the snippet list, see Section 8.1.5, “SQL Additions - Snippets Tab”.
Beautify/reformat the SQL script: By default, SQL keywords are changed to uppercase. This functionality can be changed from the SQL Execution section of the MySQL Workbench Preferences dialog.
Show the Find panel for the editor: Click to close the panel.
Toggle display of invisible characters: When selected, displays invisible characters, such as newlines, spaces, and tabs. A new line is represented as [LF], a space as a single dot (.), and a tab as a right arrow.
Toggle wrapping of long lines: When selected, wraps long lines in the SQL editor to eliminate the need to scroll. Deselecting this feature for long files is recommended.