真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Oracle怎么查詢表空間的使用情況

本篇內(nèi)容介紹了“Oracle怎么查詢表空間的使用情況”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

北票ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書(shū)銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書(shū)合作)期待與您的合作!

--查詢表空間使用情況
SELECT UPPER(F.TABLESPACE_NAME) "表空間名",
D.TOT_GROOTTE_MB "表空間大小(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空間(M)",
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') || '%' "使用比",
F.TOTAL_BYTES "空閑空間(M)",
F.MAX_BYTES "最大塊(M)"
FROM (SELECT TABLESPACE_NAME,
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 1;
--查詢表空間的free space
select tablespace_name,
count(*) as extends,
round(sum(bytes) / 1024 / 1024, 2) as MB,
sum(blocks) as blocks
from dba_free_space
group by tablespace_name;


--查詢表空間的總?cè)萘?/strong>
select tablespace_name, sum(bytes) / 1024 / 1024 as MB
from dba_data_files
group by tablespace_name;


--查詢表空間使用率
select total.tablespace_name,
round(total.MB, 2) as Total_MB,考試大論壇
round(total.MB - free.MB, 2) as Used_MB,
round((1 - free.MB / total.MB) * 100, 2) || '%' as Used_Pct
from (select tablespace_name, sum(bytes) / 1024 / 1024 as MB
from dba_free_space
group by tablespace_name) free,
(select tablespace_name, sum(bytes) / 1024 / 1024 as MB
from dba_data_files
group by tablespace_name) total
where free.tablespace_name = total.tablespace_name;

1.查找當(dāng)前表級(jí)鎖的SQL如下:
select sess.sid, 
    sess.serial#, 
    lo.oracle_username, 
    lo.os_user_name, 
    ao.object_name, 
    lo.locked_mode 
    from v$locked_object lo, 
    dba_objects ao, 
    v$session sess 
where ao.object_id = lo.object_id and lo.session_id = sess.sid;

2.殺掉鎖表進(jìn)程:
alter system kill session '436,35123';

3.RAC環(huán)境中鎖查找:
SELECT inst_id,DECODE(request,0,'Holder: ','Waiter: ')||sid sess, 
        id1, id2, lmode, request, type,block,ctime
FROM GV$LOCK
WHERE (id1, id2, type) IN
       (SELECT id1, id2, type FROM GV$LOCK WHERE request>0)
ORDER BY id1, request;
  


4.監(jiān)控當(dāng)前數(shù)據(jù)庫(kù)誰(shuí)在運(yùn)行什么SQL語(yǔ)句 
select osuser, username, sql_text  
from  v$session a, v$sqltext b 
where  a.sql_address =b.address order by address, piece;

5.找使用CPU多的用戶session 
select a.sid,spid,status,substr(a.program,1,40) prog, a.terminal,osuser,value/60/100 value 
from  v$session a,v$process b,v$sesstat c 
where  c.statistic#=12 and  
       c.sid=a.sid and  
       a.paddr=b.addr  
       order by value desc;


6.查看死鎖信息
SELECT (SELECT username
          FROM v$session
         WHERE SID = a.SID) blocker, a.SID, 'is blocking',
       (SELECT username
          FROM v$session
         WHERE SID = b.SID) blockee, b.SID
  FROM v$lock a, v$lock b
 WHERE a.BLOCK = 1 AND b.request > 0 AND a.id1 = b.id1 AND a.id2 = b.id2;


7.具有最高等待的對(duì)象
SELECT   o.OWNER,o.object_name, o.object_type, a.event,
         SUM (a.wait_time + a.time_waited) total_wait_time
    FROM v$active_session_history a, dba_objects o
   WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
     AND a.current_obj# = o.object_id
GROUP BY o.OWNER,o.object_name, o.object_type, a.event
ORDER BY total_wait_time DESC;


SELECT   a.session_id, s.osuser, s.machine, s.program, o.owner, o.object_name,
         o.object_type, a.event,
         SUM (a.wait_time + a.time_waited) total_wait_time
    FROM v$active_session_history a, dba_objects o, v$session s
   WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
     AND a.current_obj# = o.object_id
     AND a.session_id = s.SID
GROUP BY o.owner,
         o.object_name,
         o.object_type,
         a.event,
         a.session_id,
         s.program,
         s.machine,
         s.osuser
ORDER BY total_wait_time DESC;

8.查詢當(dāng)前連接會(huì)話數(shù)
select s.value,s.sid,a.username
from 
v$sesstat S,v$statname N,v$session A
where 
n.statistic#=s.statistic# and
name='session pga memory'
and s.sid=a.sid
order by s.value;

9.等待最多的用戶
SELECT   s.SID, s.username, SUM (a.wait_time + a.time_waited) total_wait_time
    FROM v$active_session_history a, v$session s
   WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
GROUP BY s.SID, s.username
ORDER BY total_wait_time DESC;

10.等待最多的SQL
SELECT   a.program, a.session_id, a.user_id, d.username, s.sql_text,
         SUM (a.wait_time + a.time_waited) total_wait_time
    FROM v$active_session_history a, v$sqlarea s, dba_users d
   WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
     AND a.sql_id = s.sql_id
     AND a.user_id = d.user_id
GROUP BY a.program, a.session_id, a.user_id, s.sql_text, d.username;

11.查看消耗資源最多的SQL
SELECT hash_value, executions, buffer_gets, disk_reads, parse_calls
FROM V$SQLAREA
WHERE buffer_gets > 10000000 OR disk_reads > 1000000
ORDER BY buffer_gets + 100 * disk_reads DESC;

12.查看某條SQL語(yǔ)句的資源消耗
SELECT hash_value, buffer_gets, disk_reads, executions, parse_calls
FROM V$SQLAREA
WHERE hash_Value = 228801498 AND address = hextoraw('CBD8E4B0');


13.查詢會(huì)話執(zhí)行的實(shí)際SQL
SELECT   a.SID, a.username, s.sql_text
    FROM v$session a, v$sqltext s
   WHERE a.sql_address = s.address
     AND a.sql_hash_value = s.hash_value
     AND a.status = 'ACTIVE'
ORDER BY a.username, a.SID, s.piece;


14.顯示正在等待鎖的所有會(huì)話
SELECT * FROM DBA_WAITERS;

“Oracle怎么查詢表空間的使用情況”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!


網(wǎng)站標(biāo)題:Oracle怎么查詢表空間的使用情況
文章起源:http://weahome.cn/article/joghph.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部