監控oracle的觸發器語句(轉)
監控oracle的觸發器語句(轉)[@more@]首先建一個日誌表,然後分別建立3個觸發器
create table EVENTLOG
(
EVENTNAME VARCHAR2(20) not null,
OPER_TIME DATE default sysdate,
INST_NUM NUMBER,
DB_NAME VARCHAR2(50),
SRV_ERROR NUMBER,
USERNAME VARCHAR2(30),
OBJ_TYPE VARCHAR2(20),
OBJ_NAME VARCHAR2(30),
OBJ_OWNER VARCHAR2(30)
)
create or replace trigger trig_ddl
after create or alter or drop on database
declare
event varchar2(20);
typ varchar(20);
name varchar(30);
owner varchar(30);
begin
--讀取DDL事件屬性
event:=sysevent;
typ:=dictionary_obj_type;
name:=dictionary_obj_name;
owner:=dictionary_obj_owner;
insert into eventlog(eventname,obj_type,obj_name,obj_owner)
values(event,typ,name,owner);
end ;
create or replace trigger trig_shutdown
before LOGOFF or shutdown on database
declare
event varchar2(20);
instance number;
dbname varchar(50);
user varchar(30);
begin
event:=sysevent;
if event = 'LOGOFF' then
user:=login_user;
insert into eventlog(eventname,username)
values(event,user);
else
instance:=instance_num;
dbname:=database_name;
insert into eventlog(eventname,inst_num,db_name)
values(event,instance,dbname);
end if;
end ;
create or replace trigger trig_startup
after LOGON or STARTUP or SERVERERROR on database
declare
event varchar2(20);
instance number;
dbname varchar(50);
err_num number;
user varchar(30);
begin
event:=sysevent;
if event = 'LOGON' then
user:=login_user;
insert into eventlog(eventname,username)
values(event,user);
elsif event = 'SERVERERROR' then
err_num:=server_error(1);
insert into eventlog(eventname,srv_error)
values(event,err_num);
else
instance:=instance_num;
dbname:=database_name;
insert into eventlog(eventname,inst_num,db_name)
values(event,instance,dbname);
end if;
end ;
create table EVENTLOG
(
EVENTNAME VARCHAR2(20) not null,
OPER_TIME DATE default sysdate,
INST_NUM NUMBER,
DB_NAME VARCHAR2(50),
SRV_ERROR NUMBER,
USERNAME VARCHAR2(30),
OBJ_TYPE VARCHAR2(20),
OBJ_NAME VARCHAR2(30),
OBJ_OWNER VARCHAR2(30)
)
create or replace trigger trig_ddl
after create or alter or drop on database
declare
event varchar2(20);
typ varchar(20);
name varchar(30);
owner varchar(30);
begin
--讀取DDL事件屬性
event:=sysevent;
typ:=dictionary_obj_type;
name:=dictionary_obj_name;
owner:=dictionary_obj_owner;
insert into eventlog(eventname,obj_type,obj_name,obj_owner)
values(event,typ,name,owner);
end ;
create or replace trigger trig_shutdown
before LOGOFF or shutdown on database
declare
event varchar2(20);
instance number;
dbname varchar(50);
user varchar(30);
begin
event:=sysevent;
if event = 'LOGOFF' then
user:=login_user;
insert into eventlog(eventname,username)
values(event,user);
else
instance:=instance_num;
dbname:=database_name;
insert into eventlog(eventname,inst_num,db_name)
values(event,instance,dbname);
end if;
end ;
create or replace trigger trig_startup
after LOGON or STARTUP or SERVERERROR on database
declare
event varchar2(20);
instance number;
dbname varchar(50);
err_num number;
user varchar(30);
begin
event:=sysevent;
if event = 'LOGON' then
user:=login_user;
insert into eventlog(eventname,username)
values(event,user);
elsif event = 'SERVERERROR' then
err_num:=server_error(1);
insert into eventlog(eventname,srv_error)
values(event,err_num);
else
instance:=instance_num;
dbname:=database_name;
insert into eventlog(eventname,inst_num,db_name)
values(event,instance,dbname);
end if;
end ;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617731/viewspace-962928/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle常用效能監控語句解析Oracle
- Oracle 資料庫監控SQL語句Oracle資料庫SQL
- mysql繞過行觸發器,實現語句觸發器MySql觸發器
- Oracle-監控sql語句的過載率OracleSQL
- 觸發器中獲取SQL語句觸發器SQL
- ORACLE:使用tcpdump 監控客戶端發過來的所有SQL語句OracleTCP客戶端SQL
- oracle使用觸發器監控哪使用者刪除了表記錄Oracle觸發器
- Oracle使用系統級觸發器審計重要帳號的DDL語句Oracle觸發器
- 使用系統級觸發器禁用DDL語句觸發器
- ORACLE監控DML語句的一些資料的彙總Oracle
- 指令碼:監控當前活動的語句指令碼
- oracle監控資料泵匯入和匯出的sql語句OracleSQL
- oracle自動生成編譯所有函式、儲存過程、觸發器的語句Oracle編譯函式儲存過程觸發器
- Oracle版本不同, 登入觸發器常用的語句返回值不一樣Oracle觸發器
- 監控使用高cpu的sql語句指令碼SQL指令碼
- Oracle使用審計監控使用者執行過的SQL語句OracleSQL
- Oracle觸發器Oracle觸發器
- Oracle觸發器觸發級別Oracle觸發器
- ORACLE 觸發器語法及例項 一Oracle觸發器
- ORACLE 觸發器語法及例項 二Oracle觸發器
- ORACLE 觸發器語法及例項 三Oracle觸發器
- 利用觸發器監控對某個表操作的使用者資訊觸發器
- Oracle檢視錶、儲存過程、觸發器、函式等物件定義語句Oracle儲存過程觸發器函式物件
- Oracle常用監控SQL(轉)OracleSQL
- ORACLE DDL觸發器Oracle觸發器
- Oracle之觸發器Oracle觸發器
- oracle ddl 觸發器Oracle觸發器
- oracle 觸發器的例項Oracle觸發器
- Oracle觸發器6(建立系統事件觸發器)Oracle觸發器事件
- 根據業務寫觸發器(oracle觸發器片)觸發器Oracle
- 效能監控方面的一些SQL語句SQL
- Oracle 行轉列的sql語句OracleSQL
- 使用自治事務在觸發器中執行DDL語句示例觸發器
- ORACLE觸發器詳解Oracle觸發器
- Oracle登陸觸發器Oracle觸發器
- oracle 觸發器-表同步Oracle觸發器
- Oracle 登入觸發器Oracle觸發器
- oracle 觸發器 client 事件Oracle觸發器client事件