Sunday, December 13, 2009

Uses of Triggers

Uses of Triggers
Triggers supplement the standard capabilities of your database to provide a highly customized database management system. For example, you can use triggers to:
• Automatically generate derived column values
• Enforce referential integrity across nodes in a distributed database
• Enforce complex business rules
• Provide transparent event logging
• Provide auditing
• Maintain synchronous table replicates
• Gather statistics on table access
• Modify table data when DML statements are issued against views
• Publish information about database events, user events, and SQL statements to subscribing applications
• Restrict DML operations against a table to those issued during regular business hours
• Enforce security authorizations
Prevent invalid transactionsPrivileges Required to Use Triggers
To create a trigger in your schema:
• You must have the CREATE TRIGGER system privilege
• One of the following must be true:
o You own the table specified in the triggering statement
o You have the ALTER privilege for the table specified in the triggering statement
o You have the ALTER ANY TABLE system privilege
To create a trigger in another schema, or to reference a table in another schema from a trigger in your schema:
• You must have the CREATE ANY TRIGGER system privilege.
• You must have the EXECUTE privilege on the referenced subprograms or packages.
To create a trigger on the database, you must have the ADMINISTER DATABASE TRIGGER privilege. If this privilege is later revoked, you can drop the trigger but not alter it.
The object privileges to the schema objects referenced in the trigger body must be granted to the trigger owner explicitly (not through a role). The statements in the trigger body operate under the privilege domain of the trigger owner, not the privilege domain of the user issuing the triggering statement (this is similar to the privilege model for stored subprograms).

No comments:

Post a Comment