MySQL Query Browser Quick Start Guide
Welcome to MySQL Query Browser
The MySQL Query Browser is a graphical
shell where you can execute queries and develop SQL scripts, with
several features to help you improve your productivity.
This short guide will guide you through the main features available in the MySQL Query Browser
and will to show you how to use most of the basic functionality available.
For full documentation, please refer to the MySQL Query Browser User Manual.
The MySQL Query Browser interface tries to mimic the interface of a web browser.
Therefore, many of the features you normally find in a web browser are
also available here, such as Back/Next navigation, query
bookmarks and query history.
Executing SQL Queries
Selecting the Default Schema
Before executing queries, you must select the
default schema that you will be
working on. You can select that by:
- typing the name of the schema you want to use in the connection
dialog, when starting the program;
- through the Select Schema...
command in the File menu; or
- by directly selecting the desired schema in the Schemata list and
selecting Set as Default Schema,
from the right click popup menu.
All subsequent queries will be executed using that schema by default.
Executing SQL Statements
The main query bar is located at the top of the window and contains
navigation buttons and the query entry box. You can execute
SQL statements by typing them in that field and pressing the
Execute button (or by pressing Control-Enter). The results of SELECT
statements are shown in the main area below.
Editing Resultsets
If the query resultset is editable, you can click the
Edit button below the resultset
view. Double clicking cells in the resultset will allow you to edit their
contents. Changes are commited to the database only after the
Apply Changes button is pressed.
For a resultset to be editable, the following conditions must be met:
- the resultset must contain columns from no more than one single
table;
- the queried columns must be proper column names (e.g: no
functions, such as in
SELECT max(price) FROM products
);
- this table must contain a Primary Key column, although not
necessarily in the query. If the query does not contain the primary
key, it will be automatically added before the MySQL Query Browser sends the query to the
MySQL server, but will display only the columns you requested;
Comparing Resultsets
You can compare two resultsets that contain the same column names
with the same datatypes, for example, to compare the differences of a
backed up version of a table with its up-to-date counterpart. For that,
split the resultset area in 2 (through the right-click popup menu from
the resultset area), execute one of the queries selecting the top
resulset view and the second query after selecting the bottom resultset
view. Once you press the Compare
button, the contents of the resultsets will be sorted and compared
side-by-side, with different colors.
Query History and Bookmarks
Every query that you execute will be recorded in the History. You can
return to previously executed queries by pressing the Back button in
the top toolbar, by double clicking the desired entry in the History
browser, at the right of the main window or by dragging the query you
want and dropping to the query editor area or directly in the resultset
view.
To bookmark a query, press Control-D. A dialog will request a name for
the query bookmark, which will be listed in the Bookmarks list. To
retrieve a bookmark, you can use the same actions as for the History.
Query Composition
The MySQL Query Browser supports some very handy "query composition" features. You can quickly
build SQL queries with drag&drop and mouse clicks.
By selecting a table from the database list and dragging it over the query
entry box, an action bar with some query composition actions will pop-up.
Drop the table you're dragging on the desired action and the query will be
modified accordingly. The following actions are possible:
- SELECT will replace the current query with a SELECT statement
containing the dragged table;
- Add Table will add the dragged table to the list of tables in the
current SELECT statement;
- JOIN Table if a SELECT statement is already in the query box, with
a table in it, the new dragged table will be added and the appropriate WHERE
clauses to perform a JOIN will be added;
- LEFT OUTER JOIN same as the previous, but will do a LEFT OUTER
JOIN instead of a JOIN;
- UPDATE will replace the current query with an UPDATE statement
containing the dragged table;
- INSERT will replace the current query with an INSERT statement
containing the dragged table;
- DELETE will replace the current query with an DELETE statement
containing the dragged table.
Also, dragging and dropping a table directly to the query box or double-clicking a
table in the database list, will compose a new SELECT statment.