To add a routine, double-click the Add
Routine
icon in the Physical
Schemata
section of the MySQL Model
page. The default name of the routine is
routine1
. If a routine with this name already
exists, the new routine is named routine2
.
Adding a new routine automatically opens the routine editor docked at the bottom of the application. For information about using the routine editor, see Section 9.1.6.1.2, “The Routine Editor”.
Right-clicking a routine opens a pop-up menu with the following items:
The
item opens the routine editor.The cut and paste items are useful for copying routines between different schemata.
Deleting the code for a routine from the Routines tab of the Routine Group Editor results in removal of the routine object from the model.
To remove a routine from a routine group, use the controls on the Routine Group tab of the Routine Group Editor.
The action of the delete option varies depending upon how you have configured MySQL Workbench. For more information, see Section 3.2.4, “Modeling Preferences”.
To invoke the routine editor, double-click a routine in the
Physical Schemata
section on the
MySQL Model
page. This opens the routine
editor docked at the bottom of the application. Any number of
routines may be open at the same time. Each additional routine
appears as a tab at the top of the routine editor.
Routine and Privileges tabs appear at the bottom of the routine editor. Navigate between different tabs using the mouse or from the keyboard by pressing Control+Alt+Tab.
Use the Routine tab of the routine editor to perform the following tasks:
Rename the routine using the Name field.
Enter the SQL to create a routine using the SQL field.
The Privileges tab of the routine editor allows you to assign specific roles and privileges. You may also assign privileges to a role using the role editor. For a discussion of this topic, see Section 9.1.1.5.2, “Adding Roles and Object Privileges”.
When this tab is first opened, all roles that have been created are displayed in the list on the right. Move the roles you wish to associate with this table to the Roles list on the left. Do this by selecting a role and then clicking the button. Use the Shift key to select multiple contiguous roles and the Control key to select noncontiguous roles.
To assign privileges to a role, click the role in the Roles list. This displays all available privileges in the Assigned Privileges list. The privileges that display are:
ALL
CREATE
DROP
GRANT OPTION
REFERENCES
ALTER
DELETE
INDEX
INSERT
SELECT
UPDATE
TRIGGER
You can choose to assign all privileges to a specific role or
any other privilege as listed previously. Privileges
irrelevant to a specific table, such as the
FILE
privilege, are not shown.
If a role has already been granted privileges on a specific table, those privileges show as already checked in the Assigned Privileges list.