System表空間不足的報(bào)警問(wèn)題淺析
廢話不多說(shuō)了,具體代碼如下所示:
--SYSTEM表空間不足的報(bào)警
登錄之后,查詢,發(fā)現(xiàn)是sys.aud$占的地方太多。
SQL> select owner, segment_name, segment_type, sum(bytes)/1024/1024 space_m
from dba_segments
where tablespace_name = 'SYSTEM'
group by owner, segment_name, segment_type
having sum(bytes)/1024/1024 >= 20
order by space_m desc
;
4 5 6 7
OWNER SEGMENT_NAME SEGMENT_TYPE SPACE_M
-------- ------------------------------- -------
SYS AUD$ TABLE 4480
SYS IDL_UB1$ TABLE 272
SYS SOURCE$ TABLE 72
SYS IDL_UB2$ TABLE 32
SYS C_OBJ#_INTCOL# CLUSTER 27
SYS C_TOID_VERSION# CLUSTER 24
6 rows selected.
SQL>
查看是哪個(gè)記得比較多。
col userhost format a30
select userid, userhost, count(1) from sys.aud$
where ntimestamp# >=CAST(to_date('2014-03-01 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
group by userid, userhost
having count(1) > 500
order by count(1) desc
;
再繼續(xù)找哪天比較多。
select to_char(ntimestamp#, 'YYYY-MM-DD') audit_date, count(1)
from sys.aud$
where ntimestamp# >=CAST(to_date('2014-03-01 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and userid = 'xxxx' and userhost = 'xxxx'
group by to_char(ntimestamp#, 'YYYY-MM-DD')
order by count(1) desc
;
select spare1, count(1) from sys.aud$
where ntimestamp# between CAST(to_date('2014-03-10 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and CAST(to_date('2014-03-11 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and userid = 'xxxx' and userhost = 'xxxx'
group by spare1
;
select action#, count(1) from sys.aud$
where ntimestamp# between CAST(to_date('2014-03-10 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and CAST(to_date('2014-03-11 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and userid = 'xxxx' and userhost = 'xxxx'
and spare1 = 'xxxx'
group by action#
order by count(1) desc
;
結(jié)果如下:
ACTION# COUNT(1)
---------- ----------
101 124043
100 124043
SQL>
其實(shí)是上次打開(kāi)的audit一直沒(méi)有關(guān)閉。
關(guān)閉:
SQL> noaudit session;
清空:
truncate table sys.aud$;
------------------------------------------------------------------------
實(shí)戰(zhàn)
------------------------------------------------------------------------
--1,查詢表空間占用情況
select dbf.tablespace_name as tablespace_name,
dbf.totalspace as totalspace,
dbf.totalblocks as totalblocks,
dfs.freespace freespace,
dfs.freeblocks freeblocks,
(dfs.freespace / dbf.totalspace) * 100 as freeRate
from (select t.tablespace_name,
sum(t.bytes) / 1024 / 1024 totalspace,
sum(t.blocks) totalblocks
from DBA_DATA_FILES t
group by t.tablespace_name) dbf,
(select tt.tablespace_name,
sum(tt.bytes) / 1024 / 1024 freespace,
sum(tt.blocks) freeblocks
from DBA_FREE_SPACE tt
group by tt.tablespace_name) dfs
where trim(dbf.tablespace_name) = trim(dfs.tablespace_name)
--2,查看哪里占的比較多 SYSTEM 為step1中查詢 tablespace_name 內(nèi)容
select owner, segment_name, segment_type, sum(bytes)/1024/1024 space_m
from dba_segments
where tablespace_name = 'SYSTEM'
group by owner, segment_name, segment_type
having sum(bytes)/1024/1024 >= 20
order by space_m desc
--3,查看是哪個(gè)記得比較多 count(1) 越大,說(shuō)明占得比較多
select userid, userhost, count(1) from sys.aud$
where ntimestamp# >=CAST(to_date('2014-03-01 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
group by userid, userhost
having count(1) > 500
order by count(1) desc
--4,再繼續(xù)找哪天比較多 userid userhost 為上一步查詢內(nèi)容
select to_char(ntimestamp#, 'YYYY-MM-DD') audit_date, count(1)
from sys.aud$
where ntimestamp# >=CAST(to_date('2015-03-01 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and userid = 'userid' and userhost = 'userhost'
group by to_char(ntimestamp#, 'YYYY-MM-DD')
order by count(1) desc
;
select spare1, count(1) from sys.aud$
where ntimestamp# between CAST(to_date('2016-03-10 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and CAST(to_date('2016-12-11 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and userid = 'userid' and userhost = 'userhost'
group by spare1
;
--spare1 為上一步查詢內(nèi)容
select action#, count(1) from sys.aud$
where ntimestamp# between CAST(to_date('2016-03-10 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and CAST(to_date('2016-12-11 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP)
and userid = 'userid' and userhost = 'userhost'
and spare1 = 'Administrator'
group by action#
order by count(1) desc
--5,關(guān)閉seeion
noaudit session;
--6,清空:
truncate table sys.aud$;
總結(jié)
以上所述是小編給大家介紹的System表空間不足的報(bào)警,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
SQL Server中的集合運(yùn)算: UNION, EXCEPT和INTERSECT示例代碼詳解
這篇文章主要介紹了SQL Server中的集合運(yùn)算: UNION, EXCEPT和INTERSECT,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-08-08
通過(guò)navicat連接SQL?Server數(shù)據(jù)庫(kù)的詳細(xì)步驟
本文介紹如何通過(guò)navicat連接SQL?Server數(shù)據(jù)庫(kù),以往總是使SQL?Server客戶端來(lái)連接SQL?Server數(shù)據(jù)庫(kù),但是SQL?Server客戶端一般有幾百M(fèi)的大小,而且安裝繁瑣配置麻煩,如果可以通過(guò)Navicat直接連接SQL?Server則會(huì)非常輕松方便,需要的朋友可以參考下2023-12-12
SQL注入語(yǔ)義分析庫(kù)libinjection簡(jiǎn)介
libinjection是一款用于防御SQL注入攻擊的開(kāi)源軟件庫(kù),它可以通過(guò)對(duì)不同語(yǔ)句進(jìn)行詞法分析和語(yǔ)法分析來(lái)實(shí)現(xiàn)對(duì)SQL語(yǔ)句以及HTML語(yǔ)句的解析,這篇文章主要介紹了SQL注入語(yǔ)義分析庫(kù)libinjection,需要的朋友可以參考下2023-03-03
SQL Server 數(shù)據(jù)庫(kù)分區(qū)分表(水平分表)詳細(xì)步驟
最近幾個(gè)擔(dān)心網(wǎng)站數(shù)據(jù)量大會(huì)影響sqlserver數(shù)據(jù)庫(kù)的性能,所以提前將數(shù)據(jù)庫(kù)分表處理好,下面是ExceptionalBoy同學(xué)分享的詳細(xì)方法,需要的朋友可以參考下2021-03-03
sqlserver數(shù)據(jù)庫(kù)主鍵的生成方式小結(jié)(sqlserver,mysql)
嚴(yán)格講這三種產(chǎn)生方式有一定的交叉點(diǎn),其定位方式將在下面進(jìn)行講解2012-07-07
sql刪除重復(fù)數(shù)據(jù)的詳細(xì)方法
重復(fù)數(shù)據(jù),通常有兩種:一是完全重復(fù)的記錄,也就是所有字段的值都一樣;二是部分字段值重復(fù)的記錄2013-05-05
數(shù)據(jù)庫(kù)設(shè)計(jì)三大范式簡(jiǎn)析
這篇文章主要介紹了數(shù)據(jù)庫(kù)設(shè)計(jì)三大范式簡(jiǎn)析,遵循范式是為了建立冗余較小、結(jié)構(gòu)合理的數(shù)據(jù)庫(kù),需要學(xué)習(xí)數(shù)據(jù)庫(kù)設(shè)計(jì)三大范式的朋友可以參考下2015-08-08
未公開(kāi)的SQL Server口令的加密函數(shù)
未公開(kāi)的SQL Server口令的加密函數(shù)...2006-07-07

