Support for triggers is included beginning with MySQL 5.0.2.
A trigger is a named database object that is associated with
a table and that is activated when a particular event occurs
for the table.
Create or Edit a Trigger
- Open the table in Design View
- Select the Triggers tab
- To add a new trigger, click Add Trigger button from the
toolbar
- Use the Trigger Name edit box to set the trigger name.
- Choose the fires action from the list.
Fires Actions
| BEFORE / AFTER |
The keyword BEFORE indicates the trigger
action time. In this case, the trigger should activate
before each row inserted into the table. The other
allowable keyword here is AFTER. |
- Select trigger event. This indicates the kind of statement that activates the trigger.
It can be one of the following:
Insert
The trigger is activated whenever a new row is inserted into the table.
For example, INSERT, LOAD DATA, and REPLACE statements.
Update
The trigger is activated whenever a row is modified.
For example, UPDATE statement.
Delete
The trigger is activated whenever a row is deleted from the table. For example,
DELETE and REPLACE statement. However, DROP TABLE and
TRUNCATE statements on the table do not activate the trigger.
- Define Statement.
- Click
Save or Save
As from the toolbar when you are ready to save the table.
Delete a Trigger
- Open the table in Design View
- Select the Triggers tab
- Select the trigger you want to delete and click Delete
Trigger button from the toolbar
- Click
Save or
Save As from the toolbar when you are ready to save the
table
|