oracle查询历史操作记录
示例:
SELECT
substr( a.sql_text, 1, 256 ) "SQL Text",
( SELECT b1.username FROM all_users b1 WHERE b1.user_id = a.parsing_user_id ) "Parsing User Name",
a.users_executing "Users Executing",
a.rows_processed "Rows Processed",
a.loads "Loads",
a.sorts "Sorts",
a.parse_calls "Parse Calls",
a.disk_reads "Disk Reads",
a.buffer_gets "Buffer Gets",
a.persistent_mem "Persistent Memory",
a.runtime_mem "Runtime Memory",
a.sharable_mem "Sharable Memory",
a.kept_versions "Kept Versions",
a.loaded_versions "Loaded Versions",
a.serializable_aborts "Serializable Aborts",
a.invalidations "Invalidations",
a.first_load_time "First Load Time",
a.cpu_time "CPU Time ",
a.elapsed_time "Elapsed Time",
a.optimizer_mode "Optimizer Mode",
a.command_type "Command Type ",
a.executions "Executions",
a.fetches "fetches",
a.address || ':' || a.hash_value "SQL Address & Hash Value",
a.sql_id "SQL Id"
FROM
v$sqlarea a
WHERE
substr(a.sql_text,0,6) = 'delete'
AND TO_DATE(a.first_load_time,'yyyy-mm-dd hh24:mi:ss') > to_date('2022/1/24 14:00:00','yyyy-mm-dd hh24:mi:ss')
and a.sql_text LIKE '%plm_cusl_lkprtrqbilltofile%'
a.parsing_user_id != ( SELECT b1a.user_id FROM all_users b1a WHERE b1a.username = 'SYS' )
AND nls_upper( a.sql_text ) LIKE : 1
AND TO_DATE(a.first_load_time,'yyyy-mm-dd hh24:mi:ss') > to_date('2022/1/24 15:00:00','yyyy-mm-dd hh24:mi:ss')
全查:
SELECT
*
FROM
v$sql
WHERE
last_load_time > '2023-03-14/15:47:20'
AND sql_text like '%d3a161b9-80dc-467e-81c6-dedcd8841c97%'
--AND sql_text not like '%8c561691-4bae-4425-a8bb-c4e8bde100d8%'
AND service = 'SYS$USERS'
ORDER BY
last_load_time ASC;