In this area, you can enter SQL statements directly. The statements entered can be saved to a file or snippet for later use. At any point, you can also execute the statements you have entered.
To save a snippet of code entered into the SQL Query panel,
Save SQL to Snippets List icon in
the Snippets panel, enter a name
(optional), and click OK. The snippet can
be inserted into the SQL Query panel at any time by
double-clicking the snippet in the SQL Snippets panel.
SELECT query will display the
associated result set in the SQL View panel, directly below the
SQL Query panel. These cells are editable if MySQL Workbench is able
to determine how, as for example they are editable if a Primary
or Unique key exists within the result set. If not, MySQL Workbench
will display a "read-only" icon at the bottom-right corner of
the SQL View panel, and hovering the mouse cursor over this icon
will provide a hint as to why it's not editable.
To quickly enter the name of a table, view, or column, double-click the item in the Schemata Palette. The item name will be inserted into the SQL Query panel.
The SQL Editor has several configurable panels and windows, as described in the screenshot above.
The Output panel is located at the bottom
of MySQL Workbench. Its select box includes the
Text Output, and
History Output options.
The Action Output panel displays a summary of the communication between the script and the server, and can refer to errors or general information. Each message displays the time, action, and server response. This output is useful for troubleshooting scripts.
The Text Output panel displays a textual representation of the query, as displayed using the MySQL Console. Use Query, Execute (All or Selection) to Text to send output to this panel.
The History Output panel provides a history of SQL operations carried out. The time and SQL code for each operation is recorded. To view the executed SQL statement, click the time, and the SQL code executed will be displayed in the SQL column.
The results area of the screen shows the results from executed statements. If the script contains multiple statements, a result tab will be generated for each statemented that returned results.
MySQL Workbench handles quoting and escaping for strings entered into the results grid, so adding quotes and proper escaping here is optional.
It is possible to enter a function, or other expression, into
a field. Use the prefix
\func to prevent
MySQL Workbench from escaping quotation marks. For example, for
md5('fred'), MySQL Workbench
normally would generate the code
md5(\'fred\'). To prevent this, enter the
\func md5('fred') to ensure
that the quoting is not escaped.
The result grid panel offers the following options:
Reset: Resets all sorted columns.
Refresh: Refreshes all data by re-executing the original statement.
Filter Rows: performs a case-insensitive search of all cells. It automatically refreshes, and there is also the refresh button to perform this action manually.
Export: Writes a result set to a CSV, HTML, JSON, SQL INSERT, Excel, XML, or Tab separated file as required.
Wrap Cell Content: If the contents of a cell exceeds the cell width, then the data will be cut off with an ellipses. This option will instead wrap the contents within the cell, and adjust the cell height accordingly.
The "Refresh" button automatically adjusts the column width to match the longest string one of its cells. You may also manually adjust the column width.
Copyright © 2006, 2014, Oracle and/or its affiliates. All rights reserved. Legal Notices