监听oracle数据库的执行sql语句的方法

发布网友 发布时间:2022-04-23 13:54

我来回答

3个回答

懂视网 时间:2022-05-02 05:33

use IlluminateSupportServiceProvider; use Validator; class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { // validator extend phone Validator::extend(‘phone‘, function ($attribute, $value, $parameters) { if (preg_match(‘/^170/‘, $value)) { return false; } if (preg_match(‘/^1(3[0-9]|4[0-9]|5[0123567]|8[012567]|7[0678])d{8}$/‘, $value)) { return true; } return false; }, ‘手机号不正确‘); // DB::listen(function($query) { // Log::info($query->sql); // }); }

 

监听数据库查询语句

标签:param   数据库   one   als   support   cti   ida   class   service   

热心网友 时间:2022-05-02 02:41

#!/usr/bin/sh
export ORACLE_HOME=/oracle/app/proct/9.2.0
export NLS_LANG=american_america.ZHS16GBK
export PATH=$ORACLE_HOME/bin:$PATH

sqlplus -S "sasdda/asdasd@asdasd" <<EOF
set lines 180 pages 43 echo off feedback off
col sid format 99999
col event format a28
col machine format a15
col sql_text format a80
col user_name format a15
col object_name format a40
col owner format a15
col opname format a30

alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select sysdate run_date from al;

select a.sid,event,wait_time "waited",seconds_in_wait "time",b.sql_address,c.sql_text
from v$session_wait a,v$session b,v$sqlarea c
where a.sid=b.sid
and b.sql_address=c.address
and (event not like 'SQL*Net%'
and event not like 'rdbms%'
and event not like '%timer%');

SELECT /*+ rule */ lpad(' ', decode(l.xisn, 0, 3, 0)) || l.oracle_username user_name,
o.owner, o.object_name, o.object_type, s.sid, s.serial#
FROM v\$locked_object l, dba_objects o, v\$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
ORDER BY o.object_id, xisn DESC;

select /*+ rule */ decode(request, 0, 'holder:', 'waiter:') holder,
l.sid, l.id1, l.id2, l.lmode, l.request, l.type, l.ctime, l.block,q.sql_text
from v\$lock l, v\$session s, v\$sqlarea q
where l.sid=s.sid
and s.sql_address=q.address
and s.sql_hash_value=q.hash_value
and (l.id1, l.id2, l.type) in
(select id1, id2, type from v\$lock where request > 0)
order by id1, request;

select lp.sid,lp.elapsed_seconds "elapsed",lp.opname,lp.sql_address,s.sql_text
from v\$session_longops lp , v\$sql s
where lp.elapsed_seconds>5
and lp.sql_address=s.address
and time_remaining>0;

EXIT
EOF

我把我以前的sql抓取脚本发给你坐个参考,可以自己写一个crontab脚本,把上面语句甩到脚本里面,自己制定抓取语句时间就行了,如果是10g或11g的库,你自己在改一下语句。

热心网友 时间:2022-05-02 03:59

SELECT * FROM V$SQLAREA ORDER BY FIRST_LOAD_TIME DESC;

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com