workbench-en.a4
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 9. Creating Views<br />
You can add views to a database either from the Physical Schemata section of the MySQL Model page or from the EER<br />
Diagram.<br />
9.1. Adding Views to the Physical Schemata<br />
Double clicking the Add View icon in the Physical Schemata section of the MySQL Model page adds a view with the default<br />
name of view1. If a view with this name already exists, the new view is named view2.<br />
Adding a new view automatically op<strong>en</strong>s the view editor docked at the bottom of the application. Using the view editor is described<br />
in Section 9.3, “The View Editor”.<br />
Right clicking a table op<strong>en</strong>s a pop-up m<strong>en</strong>u with the following options:<br />
• RENAME<br />
• CUT 'VIEW_NAME'<br />
• COPY 'VIEW_NAME'<br />
• EDIT VIEW...<br />
• EDIT IN NEW WINDOW<br />
• COPY SQL TO CLIPBOARD<br />
• DELETE 'VIEW_NAME'<br />
If the table editor is not op<strong>en</strong> the EDIT VIEW ... option op<strong>en</strong>s it. If it is already op<strong>en</strong>, the selected table replaces the previous one.<br />
EDIT IN NEW WINDOW op<strong>en</strong>s a new view editor tab.<br />
The cut and copy options are useful for copying views betwe<strong>en</strong> differ<strong>en</strong>t schemata and COPY SQL TO CLIPBOARD copies the CRE-<br />
ATE VIEW statem<strong>en</strong>t to the clipboard.<br />
Warning<br />
Use the DELETE 'VIEW_NAME' to remove a view from the database. There will be no confirmation dialog box.<br />
Any views added to the Physical Schemata also show up in the Catalog palette on the right side of the application. They<br />
may be added to an EER Digram by dragging and dropping them from this palette.<br />
9.2. Adding Views to an EER Diagram<br />
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<br />
tab is selected, and right click the view icon on the vertical toolbar. The view icon is the two overlapping rectangles found<br />
below the table icon.<br />
Clicking the mouse on this icon changes the mouse pointer to a view pointer. You can also change the mouse pointer to a view<br />
pointer by pressing the V key.<br />
Choosing the View tool changes the cont<strong>en</strong>ts of the toolbar that appears immediately below the m<strong>en</strong>u bar. Wh<strong>en</strong> the Views pointer<br />
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<br />
appropriate schema and color acc<strong>en</strong>t for the new view. Make sure that you associate the new view with a database. The color of<br />
your view can easily be changed later using the Properties palette.<br />
Create a view by clicking anywhere on the EER Diagram canvas. This creates a new view with the default name view1. To revert<br />
to the default mouse pointer, click the arrow icon at the top of the vertical toolbar.<br />
Right clicking a view op<strong>en</strong>s a pop-up m<strong>en</strong>u. With the exception of the delete option, these m<strong>en</strong>u options function as described in<br />
Section 9.1, “Adding Views to the Physical Schemata”. The behavior of the delete option is determined by your MySQL Workb<strong>en</strong>ch<br />
options settings. For more information, see Section 6.2.8.1, “The G<strong>en</strong>eral Tab”.<br />
9.3. The View Editor<br />
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<br />
47