各位大大們 我今天在測試查一個語法 可是不知道哪裡錯誤 可以請大大幫我看一下嗎?
select * from (
2 select count(*), e.event,
3 sum(e.total_waits) totwaits,
4 sum(e.time_waited) / 100 tottime,
5 max(e.time_waited) / 100 maxtime,
6 (sum(e.time_waited) / sum(e.total_waits)) / 100 avgtime
7 from v$session_event e , v$session s
8 where e. total_wait > 0
9 and e.event not like '%time%'
10 and e.event not like '%SQL*Net%'
11 and e.event not like '%pipe%'
12 and e.event not like '%ipc%'
13 and e.sid = s.sid
14 and e.type = 'USER'
15 group by e.event
16 order by count(*) desc)
17 where rownum < 11 ;
ERROR at line 2:
ORA-00903: invalid table name
------解决方案--------------------
对视图没有查询权限?
如果有权限,以下能够执行(没有TYPE字段)
select *
from (select count(*),
e.event,
sum(e.total_waits) totwaits,
sum(e.time_waited) / 100 tottime,
max(e.time_waited) / 100 maxtime,
(sum(e.time_waited) / sum(e.total_waits)) / 100 avgtime
from v$session_event e, v$session s
where e.total_waits > 0
and e.event not like '%time%'
and e.event not like '%SQL*Net%'
and e.event not like '%pipe%'
and e.event not like '%ipc%'
and e.sid = s.sid
-- and e.type = 'USER'
group by e.event
order by count(*) desc)
where rownum < 11;
------解决方案--------------------
1、请连接dba用户执行这些语句
2、代码中部分字段错误
v$session_event没有total_wait字段,应该为total_waits
v$session_event没有type字段,v$session中有type字段