I like Oracle very much. I also like to sum up the experience and lessons of Oracle triggers in my work. Let's talk about this in detail. There are two types of Oracle triggers: after and before. The difference is that each commit transaction is triggered once and each row of data is updated once. Pay attention to this when using it to avoid failure to achieve the goal.
The syntax for Oracle to generate database triggers is:
Create [or replace] trigger name trigger time trigger event
On Table Name
[For each row]
Pl/SQL statements
Oracle trigger name: name of the trigger object. Because the trigger is automatically executed by the database, the name is only a name and has no substantive purpose.
Oracle trigger time: specifies when the trigger is executed. This value is optional:
Before --- indicates that the trigger is executed before the database action;
After --- indicates that the logpilot executes the database action.
Oracle trigger event: Specifies which database actions will trigger this trigger:
Insert: This trigger is triggered when the database is inserted;
Update: This trigger is triggered when the database is modified;
Delete: This trigger is triggered when a database is deleted.
Table Name: The table where the database trigger is located.
For each row: the trigger for each row of the table is executed once. If this option is not available, the entire table is executed only once.
For example, the following trigger is triggered before the table auths is updated to prevent
Weekend table modification:
- Create trigger auth_secure
- Before insert or update or delete
- // Triggered before update of the entire table
- On auths
- Begin
- If (to_char (sysdate, 'dy ') = 'sun'
- RAISE_APPLICATION_ERROR (-20600, 'table auths' cannot be modified on weekends ');
- End if;
- End
- Oracle object privileges
- Oracle System privileges
- Common Oracle password verification
- Brief Discussion on Oracle media recovery
- Completely kill the Oracle deadlock Process