16.6.7.3. Creating Views

You can add views to a database either from the Physical Schemata section of the MySQL Model page or from the EER Diagram.

16.6.7.3.1. Adding Views to the Physical Schemata

Double-clicking the Add View icon in the Physical Schemata section of the MySQL Model page adds a view with the default name of view1. If a view with this name already exists, the new view is named view2.

Adding a new view automatically opens the view editor docked at the bottom of the application. Using the view editor is described in Section 16.6.7.3.3, “The View Editor”.

Right-clicking a table opens a pop-up menu with the following options:

  • Cut 'view_name'

  • Copy 'view_name'

  • Paste

  • Edit View...

  • Edit in New Window

  • Copy SQL to Clipboard

  • Delete 'view_name'

If the table editor is not open the Edit View ... option opens it. If it is already open, the selected table replaces the previous one. Edit in New Window opens a new view editor tab.

The cut and copy options are useful for copying views between different schemata and Copy SQL to Clipboard copies the CREATE VIEW statement to the clipboard.

Warning

Use the Delete 'view_name' to remove a view from the database. There will be no confirmation dialog box.

Any views added to the Physical Schemata also show up in the Catalog palette on the left side of the application. They may be added to an EER Diagram, when in EER Diagram view, by dragging and dropping them from this palette.

16.6.7.3.2. Adding Views to an EER Diagram

Views can also be added to an EER Diagram using the View tool on the vertical toolbar. To do this make sure that the EER Diagram tab is selected, and left-click the view icon on the vertical toolbar. The view icon is the two overlapping rectangles found below the table icon.

Clicking this icon changes the mouse pointer to a view pointer. You can also change the mouse pointer to a view pointer by pressing the V key.

Choosing the View tool changes the contents of the toolbar that appears immediately below the main menu bar. When the Views pointer is active, this toolbar contains a drop down list box of schemata and a drop down color chart. Use these list boxes to select the appropriate schema and color accent for the new view. Make sure that you associate the new view with a database. The color of your view can easily be changed later using the Properties palette.

Create a view by clicking anywhere on the EER Diagram canvas. This creates a new view with the default name view1. To revert to the default mouse pointer, click the arrow icon at the top of the vertical toolbar.

Right-clicking a view opens a pop-up menu. With the exception of the delete option, these menu options function as described in Section 16.6.7.3.1, “Adding Views to the Physical Schemata”. The behavior of the delete option is determined by your MySQL Workbench options settings. For more information, see Section 16.4.4.4, “The Model Tab”.

16.6.7.3.3. The View Editor

You can invoke the view editor by double-clicking a view object on the EER Diagram canvas or by double-clicking a view in the Physical Schemata section on the MySQL Model page. Doing this opens the view editor docked at the bottom of the application. Double-clicking the title bar undocks the editor. Do the same to redock it. Any number of views may be open at the same time. Each additional view appears as a tab at the top of the view editor.

There are three tabs at the bottom of the view editor, the View, Comments, and the Privileges tabs. Navigate between different tabs using the mouse or from the keyboard by pressing Ctrl + Alt + Tab.

The View Tab

From the View tab of the view editor you can perform the following tasks:

  • Rename the view using the Name text box.

  • Enter the SQL to create a view using the SQL text area.

  • Comment a view using the Comments text area.

The Comments Tab

This tab enables you to enter comments for a particular view.

The Privileges Tab

The Privileges tab of the view editor functions in exactly the same way as the Privileges tab of the table editor. For more information, see Section 16.6.7.1.3.10, “The Privileges Tab”.

16.6.7.3.4. Modifying a View using the Properties Palette

When you select a view on the EER Diagram canvas, its properties are displayed in the Properties palette. Most of the properties accessible from the Properties palette apply to the appearance of a view on the EER Diagram canvas.

For a list of the properties accessible through the Properties palette see Section 16.6.5.11, “The Properties Palette”.

Copyright © 2010-2024 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout