The MySQL Query Browser

This article introduces you to the MySQL Query Browser, a visual tool for creating, executing, and optimizing SQL queries.

Last month’s “Tech Support” introduced
MySQL Administrator, a powerful, visual
administration console that enables you to easily administer your
MySQL environment and discover in great detail how your databases
are operating. However, MySQL Administrator doesn’t help much
with SQL queries.

To craft and run SQL, try the MySQL Query
, which, like MySQL Administrator, is available
directly from MySQL AB under the same dual-license as MySQL itself.
The MySQL Query Browser is a visual tool for creating, executing,
and optimizing SQL queries. The application gives you a complete
set of drag-and-drop tools to visually build, analyze, and manage
your queries. It also provides a number of other powerful features:
Use the Query Toolbar to easily create and
execute queries and navigate query history; manually create or edit
SQL statements with built-in Script Editor;
use the Results Window to compare and work
with multiple queries; manage your databases, bookmarks, and
history using a web browser-like interface in the "i">Object Browser; and select tables and fields to query,
and create and delete tables with the Database
and Table Editor.

You can obtain both MySQL Administrator and MySQL Query Browser
by downloading the MySQL GUI Tools Bundle
from class=
Binaries for all major platforms and source code are available, and
binary installation is a snap.

Once you have the software on your system, fire it up and take a
look at what it can actually do. To launch the product, type:

$ mysql-query-browser

The first thing you’ll notice on startup is the same
credentials window presented by MySQL Administrator, including any
stored connections you created previously. Choose a previous
connection, enter the appropriate credentials, and hit the Connect
button to open the main window.

class="story_image"> "http://www.linux-mag.com/images/2007-01/tech/fig1.png" class=

Near the very top is the query area. This area allows you to
manually enter SQL statements or build them visually. Below that
and on the left is the results area, which contains output from
commands entered in the query area. You’ll notice it acts
similarly to a web browser, and even includes full tabbed browsing

Moving to the right is the Object Browser (on top) and the
Information Browser (at bottom). In addition to the capabilities
mentioned above, the Object Browser allows you to bookmark common
queries and view a history of the queries you’ve run. The
Information Browser provides access to all information that is not
directly related to actual data within your database, including a
syntax reference guide, a full list of built-in MySQL functions,
and a list of local, global, and dynamic parameters.

To run a query, choose a “default schema” (a
database) by double-clicking a database in the Object Browser. You
can also create a new database by right-clicking in the Object
Browser and selecting “Create Schema.” Once you select
a database, you get a full visual layout of the tables and columns.
You can manually type SQL queries into the query window, but you
can also build them visually.

For instance, to get a full list of rows in a table,
double-click the table. The corresponding SQL query is entered for
you automatically — you just need to click the Execute

Next, drag a table or column from the Object Browser into the
query window. This presents a list of actions that can be performed
on the item you’ve dragged across. Simply drop the item on
the action you’d like to perform to build a complex query
piece-by-piece. Once you have a result set you can edit it right in
the results window. To do so, simply click the "i">Start Editing button near the bottom and right click on
the results you’d like to edit. Creating a new table is
similar to creating a new database, simply right click on the
database you’d like to alter and select Create Table.

The MySQL Query Browser also gives you access to MySQL’s
EXPLAIN feature and the ability to compare
results. If you’re using a newer version of MySQL, the Query
Browser also fully supports transactions, views, and stored

The MySQL query browser is an extremely useful tool for editing
MySQL schema and running SQL queries. If you prefer the old school
method of manually typing queries, it still provides you the
benefit of a clean interface, a full history, and the ability to
bookmark oft-run queries. If you’re not a SQL guru, it also
allows you to build queries interactively.

Comments are closed.