Monitoring table record changes using triggers

Source: Internet
Author: User
You can use database auditing, LogMiner log mining, triggers, and other methods to monitor user behavior in the database. However, the first two methods are troublesome. Using triggers can easily meet some special monitoring requirements. The following is an example of who changed the records using the trigger monitoring table: --- display the grantselectonsys. v _

You can use database auditing, LogMiner log mining, triggers, and other methods to monitor user behavior in the database. However, the first two methods are troublesome. Using triggers can easily meet some special monitoring requirements. The following is an example of who changed the records using the trigger monitoring table: --- show the two views grant the permission to all users to query grant select on sys. v _

You can use database auditing, LogMiner log mining, triggers, and other methods to monitor user behavior in the database. However, the first two methods are troublesome. Using triggers can easily meet some special monitoring requirements.

The following is an example of who changed the log using the trigger monitoring table:

--- Grant select on sys. v _ $ session to public; grant select on sys. v _ $ sqlarea to public; --- create table log_monitor_tab (SQL _text varchar2 (400), username varchar2 (30), schemaname varchar2 (30), osuser varchar2 (30 ), ip_address varchar2 (15), machine varchar2 (50), program varchar2 (50), modifytime date ); ---- create or replace trigger tri_monitor_tab before insert or update or delete on table_name -- enter the corresponding table name for each rowbegin insert into log_monitor_tab select sq. SQL _text, se. username, se. schemaname, se. osuser, SYS_CONTEXT ('userenv', 'IP _ address'), se. machine, se. program, sysdate from v $ sqlarea sq, v $ session se where sq. address = se. SQL _address and se. sid = userenv ('sid '); end; --- query the log table log_monitor_tab record select * from log_monitor_tab order by modifytime asc;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.