|
|
Want to know more about Packt's Article Network? Interested in contributing your article ideas? Please visit our FAQ for more information. See More BROWSE
All Titles WordPress Web Services SOA BPEL Web Graphics & Video Web Development RAW Portugues, Espanol, Italiano, French PHP/MySQL Oracle Open Source Networking & Telephony Moodle Microsoft & .NET Linux Servers jQuery Joomla! JBoss Java e-Learning e-Commerce Dynamics Drupal CRM Cookbook Content Management Beginner Guides Architecture and Analysis AJAX Future Titles Recently Published Titles MySQL Query Browser, one of the open source MySQL GUI tools from MySQL AB, is used for building MySQL database queries visually. In MySQL Query Browser, you build database queries using just your mouse—click, drag and drop! MySQL Query Browser has plenty of visual query building functions and features. This article Djoni Darmawikarta shows two examples, building Join and Master-detail queries. These examples will demonstrate some of these functions and features. See More |
Creating a View with MySQL Query Browser
Please refer to an earlier article by the author to learn how to build queries visually. Creating a View from an Existing QueryTo create a view from a query, you must have executed the query successfully. To be more precise, the view is created from the latest successfully executed query, not necessarily from the query currently in the Query Area. To further clarify, the following three examples are cases where the view is not created from the current query:
Additionally, if you’re changing your Resultset, the view created is from the latest successfully executed query that uses the currently active Resultset to display its output. To make sure your view is from the query you want, select the query, confirm it as written in the Query Area, execute the query, and then, immediately create its view. You create a view from an existing query by selecting Query | Create View from Select from the Menu bar.
Type in the name you want to give to the view, and then click Create View. MySQL Query Browser creates the view.
When successfully created, you can see the view in the Schemata.
You can modify a view by editing it: Right-click the view and select Edit View.
You can edit the CREATE view statement by right-clicking it and select Edit View.
The CREATE view statement opens in its Script tab. When you finish editing, you can execute the modified view. If successful, the existing view is replaced with the modified one.
To replace the view you’re editing with the modified view, change the name of the view before you execute it. If you want to keep the view you’re editing, remove the DROP VIEW statement.
Creating your MySQL Database: Practical Design Tips
and Techniques
Writing View from Scratch ManuallyWhen you right-click a table, MySQL Query Browser provides you with a skeleton CREATE view statement, in which you can write in your view definition.
Enter the name of your view.
Write view definition.
When you finish writing your view definition, click Execute to create the view.
Dropping a ViewTo drop a view just right-click the view and select Drop View.
Click OK to confirm that you really want to delete the view; the view will no longer be in the Schemata.
Saving the View as ScriptYou can save a CREATE view statement as a script file outside of MySQL Query Browser. If you later want to create or re-create the view, you can re-call the script into MySQL Query Browser and execute it. To save a CREATE view statement, you must have it in a Script tab. Right-click anywhere in the tab and select Save Script As.
Type in the name you want to give to the script file, and then click Save.
To recall a view script, select File | Open Script.
Select the script you want to open.
MySQL Query Browser opens the script in a new Script tab. You can edit the script if you need to, and then to create the view just click the Execute button.
When you’re closing the Script tab (by clicking the red cross sign on its tab header) and you made any change to the script, you’ll be prompted to save the script.
SummaryWe have just learned about the MySQL Query Browser and how it is used to create views visually and in an easy manner. Creating your MySQL Database: Practical Design Tips
and Techniques
About the AuthorDjoni Darmawikarta built his career in IBM Asia Pacific and Canada as a software engineer, international consultant, instructor and project manager, for a total of 17 years. He's currently a technical specialist in the Data Warehousing and Business Intelligence team of a Toronto-based insurance company. Outside of his office works, Djoni writes IT articles and books. Books from Packt |
TOP TITLES ![]()
SQL 2008 server is the latest in the line of Microsoft database servers and this article by Dr. Jayaram Krishnaswamy discusses the challenges one may face in installing the Developer version of this product which was released in November 2007. On a virgin machine the software probably installs without a hitch but with a history of installs, especially of the earlier versions it is anything but a joy ride. "It is almost always true for most of the software I have installed, not necessarily limited to Microsoft. However, most of Microsoft products need entry in the Window's registry and it is almost certain that one has to follow a certain protocol if one wishes to have a successful install. In fact the unsuccessful install flags out what went wrong while the initial steps do verify the requirements during installation. Despite this help and warnings one may face problems simply because it is not possible to foresee all possible combinations of hardware, software, user created error issues at launch time of the product. Again this article does not guarantee a successful install if one were to follow the steps delineated but gives you some guidance based on the author's experience." See More |
| ||||||||