Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
By jeremy at 2007-05-01 15:02
The MySQL Query Browser
By Jeremy Garcia
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 Browser, 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 Object Browser; and select tables and fields to query, and create and delete tables with the Database Explorer and Table Editor.
You can obtain both MySQL Administrator and MySQL Query Browser by downloading the MySQL GUI Tools Bundle from http://dev.mysql.com/downloads/gui-tools/5.0.html. 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:
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.
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 functionality.
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 button.
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 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 procedures.
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.