记录数据库所有ddl操作

NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
enable_ddl_logging     boolean FALSE



通过ash查询历史执行sql:
V$ACTIVE_SESSION_HISTORY
DBA_HIST_SQLTEXT

select s.*,b.SQL_TEXT from (select a.SAMPLE_TIME,a.sql_id  from V$ACTIVE_SESSION_HISTORY a where a.sql_id<>'NULL') s ,DBA_HIST_SQLTEXT b where s.sql_id=b.sql_id ;

select a.SAMPLE_TIME,a.sql_id,b.SQL_TEXT FROM  V$ACTIVE_SESSION_HISTORY a,DBA_HIST_SQLTEXT b   WHERE a.sql_id<>'NULL' AND  a.sql_id=b.sql_id
select a.SAMPLE_TIME,a.sql_id,b.SQL_TEXT FROM  V$ACTIVE_SESSION_HISTORY a,DBA_HIST_SQLTEXT b   WHERE a.sql_id<>'NULL' AND  a.sql_id=b.sql_id AND  a.SAMPLE_TIME


select a.SAMPLE_TIME,a.sql_id,b.SQL_TEXT FROM  V$ACTIVE_SESSION_HISTORY a,DBA_HIST_SQLTEXT b   WHERE a.sql_id<>'NULL' AND  a.sql_id=b.sql_id
AND  a.SAMPLE_TIME between  TO_DATE ('2017-01-16 00:00:00','yyyy-mm-dd hh24:mi:ss') and  TO_DATE ('2017-01-16 12:00:00','yyyy-mm-dd hh24:mi:ss')








SELECT  sql_id,count(*)
    FROM DBA_HIST_ACTIVE_SESS_HISTORY a
   WHERE a.SAMPLE_TIME between  TO_DATE ('2017-01-16 00:00:00','yyyy-mm-dd hh24:mi:ss') and  TO_DATE ('2017-01-16 01:00:00','yyyy-mm-dd hh24:mi:ss') group by sql_id










SELECT  sql_id,count(*)
    FROM DBA_HIST_ACTIVE_SESS_HISTORY a
   WHERE a.SAMPLE_TIME between  TO_DATE ('2017-01-16 00:00:00','yyyy-mm-dd hh24:mi:ss') and  TO_DATE ('2017-01-16 01:00:00','yyyy-mm-dd hh24:mi:ss') group by sql_id




select a.SAMPLE_TIME,a.sql_id,b.SQL_TEXT FROM  DBA_HIST_ACTIVE_SESS_HISTORY a,DBA_HIST_SQLTEXT b   WHERE a.sql_id<>'NULL' AND  a.sql_id=b.sql_id
AND  a.SAMPLE_TIME between  TO_DATE ('2017-01-16 00:20:00','yyyy-mm-dd hh24:mi:ss') and  TO_DATE ('2017-01-16 00:40:00','yyyy-mm-dd hh24:mi:ss')





来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20747382/viewspace-2132160/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/20747382/viewspace-2132160/

你可能感兴趣的:(记录数据库所有ddl操作)