Prev | Next |
Table Triggers
A Table trigger is SQL or code that is automatically executed as a result of data being modified in a database Table. Triggers are highly customizable and can be used in many different ways; for example, they could be used to stop certain database activities from being performed during business hours, or to provide validation or perform deletions in secondary Tables when a record in the primary Table is deleted.
In Enterprise Architect, a Table trigger is modeled as a stereotyped operation and managed using the Table's 'Constraints' screen.
Access
Ribbon |
Develop > Data Modeling > Database Builder > Click on Table name > Constraints/Indexes | Right-click | Add New Constraint |
Context Menu |
In diagram | Right-click on Table | Features | Constraints/Indexes | Right-click | Add New Constraint |
Keyboard Shortcuts |
Click on Table: > Constraints/Indexes: |
Create a Table Trigger
Step |
Action |
See also |
---|---|---|
1 |
On the 'Constraints/Indexes' tab, a new constraint is automatically created and assigned the default constraint name and a 'Type' of index. Overtype the constraint name with a name that identifies the constraint as a trigger, such as TRG_OnCustomerUpdate. (The TRG_ prefix is optional.) |
Database Table Constraints/Indexes |
2 |
In the 'Type' field, change the value from 'index' to 'trigger'. |
|
3 |
In the 'Properties' panel for the Statement property, type in the complete SQL statement (including CREATE TRIGGER) that will define the Trigger. If the condition is long, click on the button to display a SQL editor (with syntax highlighting). |
|
4 |
The properties Trigger Time and Trigger Event are currently information-only values and are not used in DDL generation. |
Delete a Table Trigger
If you do not want to keep a trigger, either:
- Right-click on it in the list and select 'Delete constraint <name>', or
- Click on the item and press
The trigger is immediately deleted.
Notes
- Any columns assigned to table triggers are ignored