Views

A View is a virtual table based on the result-set of a SELECT statement. A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database. You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from a single table.

Views (including updatable views) are implemented in the 5.0 version of MySQL Server, and SQLyog offers you tools to manage the views.


Create View

To create a new view, use the menu item Others -> View -> Create View.

A dialog will appear to request the view name. Once you have entered the name, a template for the view creation will be typed in a separate tab of the SQL Window. The template contains a command to drop the view in case it already exists and a command for the view creation where you have only to add your required selection of columns. You can use the WHERE clause to set selection conditions.

Use the toolbar buttons or hotkeys to execute the queries. As editor tabs of a special kind are used for views creation/alteration, pressing both F5 and Shift+F5 keys leads to execution of  all queries present in the SQL window.


Alter View

To alter an existing view, select it in the Object browser and use the menu item Others -> View -> Alter View or press F6.

A template for the view alteration will appear in a separate tab of the SQL Window. The template contains a command to drop the view in case it already exists and a command for the view re-creation where you can specify source fields and their names in the target view. Use the WHERE clause if you need to set selection conditions.

Use the toolbar buttons or hotkeys to execute the queries. As editor tabs of a special kind are used for views creation/alteration, pressing both F5 and Shift+F5 keys leads to execution of  all queries present in the SQL window.


Drop View

To drop an existing view, select it in the Object browser and use the menu item Others -> View -> Drop View. Then confirm the operation in the appeared dialog.


Rename View

To rename a view, select it in the Object browser and use the menu item Others -> View -> Rename View or simply click its name in the Object browser or press F2.