[20180525]丟失審計.txt
[20180525]丟失審計.txt
---//重複測試:
1.環境:
SCOTT@test01p> @ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
rem
rem Script: del_cascade_2.sql
rem Author: Jonathan Lewis
rem Dated: Mar 2004
rem
rem Last tested
rem 12.1.0.2
rem 11.2.0.4
rem
drop table t2 purge;
drop table t1 purge;
create table t1 (
id number(6),
v1 varchar2(10),
padding varchar2(100),
constraint t1_pk
primary key (id)
);
create table t2 (
id_par number(6),
id_ch number(6),
v1 varchar2(10),
padding varchar2(100),
constraint t2_pk
primary key (id_par,id_ch),
constraint t2_fk_t1
foreign key (id_par) references t1
on delete cascade
);
insert into t1
select
rownum,
rownum,
rpad('x',100)
from
all_objects
where
rownum <= 100 -- > comment to avoid wordpress format issue
;
insert into t2
select
1+trunc((rownum-1)/5),
rownum,
rownum,
rpad('x',100)
from
all_objects
where
rownum <= 500 -- > comment to avoid wordpress format issue
;
commit;
prompt =================================
prompt Parent/Child rowcounts for id = 1
prompt =================================
select count(*) from t1 where id = 1;
select count(*) from t2 where id_par = 1;
column now new_value m_now
select to_char(sysdate,'dd-mon-yyyy hh24:mi:ss') now from dual;
audit delete on t2 by access;
audit delete on t1 by access;
prompt =======================================================
prompt If you allow the cascade (keep the t2 delete commented)
prompt then the cascade deletion is not audited.
prompt =======================================================
-- delete from t2 where id_par = 1;
delete from t1 where id = 1;
noaudit delete on t1;
noaudit delete on t2;
column obj_name format a32
select action_name, obj_name
from user_audit_trail
where timestamp >= to_date('&m_now','dd-mon-yyyy hh24:mi:ss')
;
--//測試結果如下:
SCOTT@test01p> select count(*) from t1 where id = 1;
COUNT(*)
----------
1
SCOTT@test01p> select count(*) from t2 where id_par = 1;
COUNT(*)
----------
5
column now new_value m_now
select to_char(sysdate,'dd-mon-yyyy hh24:mi:ss') now from dual;
audit delete on t2 by access;
audit delete on t1 by access;
SCOTT@test01p> delete from t1 where id = 1;
1 row deleted.
noaudit delete on t1;
noaudit delete on t2;
column obj_name format a32
SCOTT@test01p> select action_name, obj_name from user_audit_trail where timestamp >= to_date('&m_now','dd-mon-yyyy hh24:mi:ss') ;
ACTION_NAME OBJ_NAME
-------------------- --------------------
DELETE T1
--//僅僅看到刪除T1的審計.
SCOTT@test01p> select count(*) from t1 where id = 1;
COUNT(*)
----------
0
SCOTT@test01p> select count(*) from t2 where id_par = 1;
COUNT(*)
----------
0
---//重複測試:
1.環境:
SCOTT@test01p> @ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
rem
rem Script: del_cascade_2.sql
rem Author: Jonathan Lewis
rem Dated: Mar 2004
rem
rem Last tested
rem 12.1.0.2
rem 11.2.0.4
rem
drop table t2 purge;
drop table t1 purge;
create table t1 (
id number(6),
v1 varchar2(10),
padding varchar2(100),
constraint t1_pk
primary key (id)
);
create table t2 (
id_par number(6),
id_ch number(6),
v1 varchar2(10),
padding varchar2(100),
constraint t2_pk
primary key (id_par,id_ch),
constraint t2_fk_t1
foreign key (id_par) references t1
on delete cascade
);
insert into t1
select
rownum,
rownum,
rpad('x',100)
from
all_objects
where
rownum <= 100 -- > comment to avoid wordpress format issue
;
insert into t2
select
1+trunc((rownum-1)/5),
rownum,
rownum,
rpad('x',100)
from
all_objects
where
rownum <= 500 -- > comment to avoid wordpress format issue
;
commit;
prompt =================================
prompt Parent/Child rowcounts for id = 1
prompt =================================
select count(*) from t1 where id = 1;
select count(*) from t2 where id_par = 1;
column now new_value m_now
select to_char(sysdate,'dd-mon-yyyy hh24:mi:ss') now from dual;
audit delete on t2 by access;
audit delete on t1 by access;
prompt =======================================================
prompt If you allow the cascade (keep the t2 delete commented)
prompt then the cascade deletion is not audited.
prompt =======================================================
-- delete from t2 where id_par = 1;
delete from t1 where id = 1;
noaudit delete on t1;
noaudit delete on t2;
column obj_name format a32
select action_name, obj_name
from user_audit_trail
where timestamp >= to_date('&m_now','dd-mon-yyyy hh24:mi:ss')
;
--//測試結果如下:
SCOTT@test01p> select count(*) from t1 where id = 1;
COUNT(*)
----------
1
SCOTT@test01p> select count(*) from t2 where id_par = 1;
COUNT(*)
----------
5
column now new_value m_now
select to_char(sysdate,'dd-mon-yyyy hh24:mi:ss') now from dual;
audit delete on t2 by access;
audit delete on t1 by access;
SCOTT@test01p> delete from t1 where id = 1;
1 row deleted.
noaudit delete on t1;
noaudit delete on t2;
column obj_name format a32
SCOTT@test01p> select action_name, obj_name from user_audit_trail where timestamp >= to_date('&m_now','dd-mon-yyyy hh24:mi:ss') ;
ACTION_NAME OBJ_NAME
-------------------- --------------------
DELETE T1
--//僅僅看到刪除T1的審計.
SCOTT@test01p> select count(*) from t1 where id = 1;
COUNT(*)
----------
0
SCOTT@test01p> select count(*) from t2 where id_par = 1;
COUNT(*)
----------
0
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2155136/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- JavaScript中解決計算精度丟失的問題JavaScript
- RabbitMQ防止訊息丟失MQ
- win10 計算機丟失logmanager怎麼辦 win10丟失log.dll檔案的解決方法Win10計算機
- Oracle Redo丟失恢復方案Oracle
- redirect 方法會丟失埠號
- Double BigDecimal 精度丟失總結Decimal
- 伺服器資料丟失了怎麼恢復/分割槽丟失恢復教程伺服器
- 計算機提示丟失BSE.ocx檔案如何解決?計算機
- PbootCMS前端頁面樣式丟失boot前端
- 分割槽丟失資料恢復資料恢復
- WKWebView 網路請求Header 丟失WebViewHeader
- 硬碟資料丟失如何恢復?硬碟
- git server“丟失”commit問題探究GitServerMIT
- js浮點數丟失問題JS
- Spring Mvc Long型別精度丟失SpringMVC型別
- LeetCode:尋找丟失的數字LeetCode
- GET請求的引數丟失
- GetPixelAddress()函式Alpha通道會丟失函式
- win10 ppt檔案丟失怎麼恢復_win10 ppt文件丟失如何找回Win10
- win10丟失msvbvm50.dll怎麼辦_win10提示計算機中丟失msvbvm50.dll的解決方法Win10計算機
- DM7審計之物件審計物件
- 條件變數如何避免丟失通知變數
- 重組raid會丟失資料嗎AI
- 如何找回分割槽丟失的資料
- AssetBundle在移動裝置上丟失
- JavaScript精度丟失原因以及解決方案JavaScript
- 《RabbitMQ》 | 訊息丟失也就這麼回事MQ
- SQLServer複製到execl丟失資料SQLServer
- Feign 呼叫丟失Header的解決方案Header
- RocketMq訊息丟失問題解決MQ
- RabbitMq如何確保訊息不丟失MQ
- (題號丟失)校門外的樹
- Kafka零資料丟失的配置方案Kafka
- vue重新整理頁面丟失404Vue
- Elasticsearch如何保證資料不丟失?Elasticsearch
- 深入理解JavaScript中的精度丟失JavaScript
- win10 msiexec.exe丟失怎麼修復_win10 msiexec.exe丟失如何解決Win10
- DM7審計之語句序列審計