How does Oracle9i automatically capture DML statements?

zhaozj2021-02-12  146

SQL> DESC T1NAME NULL? TYPE ---- --------

A Numbersql> Desc T_SQLNAME NULL? TYPE --------------------------- Username varchar2 (30) Client_ip varchar2 (20) SQL_Text varchar2 (4000) TABLE_NAME VARCHAR2 (30) OWNER VARCHAR2 (30) SQL> create or replace trigger capt_sql 2 BEFORE DELETE oR INSERT oR UPDATE ON t13 declare 4 n number; 5 stmt varchar2 (4000); 6 sql_text ora_name_list_t; 7 begin8 n: = ora_sql_txt (sql_text ); 9 for i in 1..n loop10 stmt: = STMT || SQL_Text (i); 11 end loop; 12 13 INSERT INTO T_SQL (username, client_ip, sql_text, table_name, oowner) Values ​​(user, sys_context (' Userenv ',' ip_address'), STMT, 'T1', 'Rainy'); 15 16 end; 17 / Trigger Created.SQL> INSERT INTO T1 (a) Values ​​(1); 1); 1 Row Created.SQL> Update T1 SET A = 2 WHERE A = 1; 1 row updated.sql> delete t1; 3 rows deled.sql> commit; commit complete.sql> select * from t_sql; username client_ip sql_text table_name Owner ---------------- ------------------------------------------------------------------------------- Rainy 10.1.30.19 INSERT INTO T1 (a) Values ​​(1) T1 Rainyrainy 10.1.30.19 Update T1 Set A = 2 WHERE A = 1 T1 RainyRainy 10.1.30. 19 Delete T1 T1 Rainy

转载请注明原文地址:https://www.9cbs.com/read-7570.html

New Post(0)