ORACLE trigger syntax
There are two types of triggers: after and before,
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
Where:
Trigger name: name of the trigger object. Because the trigger is automatically executed by the database
So the name is only a name and has no substantive purpose.
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.
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 you do not have this
To the entire table.
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 whole table
On auths
Begin
If (to_char (sysdate, 'dy ') = 'sun'
Raise_application_error (-20600, 'table auths' cannot be modified on weekends); -- the trigger can only throw an exception to implement rollback.
End if;
End