|
通过EMC连接上数据库,在 库-》存储-》表空间 中发现某个表空间使用率已经达88%,
通过DBA用户登陆,使用SQL查看表空间使用情况:
select segment_type, sum(bytes)/1024/1024 from dba_segments where tablespace_name='AA' group by segment_type; 1 INDEX 1077.9375 2 LOBINDEX 0.0625 3 LOBSEGMENT 0.0625 4 TABLE 21988.546875 可知使用最多的是表,查询哪些表占用了表空间:
select bytes/1024/1024 sizeM, owner, segment_name from dba_segments where tablespace_name = 'DD' and segment_type = 'TABLE' order by sizeM desc; 1 12113.984375 AE JAMES 2 1683 AE CATE 3 920 AE WORKLOG 4 793 AE SEVERLOG
由此可看出,最大的表是JAMES,可以对其进行清理 删除一个表的大量数据,不能直接删除,否则回滚段会溢出。 网上已经有高人写了相应的存储过程,在这里引用一下:
create or replace procedure delbigtab ( p_tablename in varchar2, p_condition in varchar2, p_count in varchar2 ) as pragma autonomous_transaction; n_delete number:=0; begin while 1=1 loop execute immediate 'delete from '||p_tablename||' where '||p_condition||' and rownum <= :rn' using p_count; if sql%notfound then exit; else n_delete:=n_delete + sql%rowcount; end if; commit; end loop; commit; dbms_output.put_line('finished! totally '||to_char(n_delete)||' records deleted!'); end; 执行此存储过程,对表JAMES删除一些历史数据,删除后表JAMES的空间缩小到9G左右
另外,表WORKLOG已经是没有用的,可以删除: truncate table worklog; drop table worklog; 由此也释放920M左右空间。
PS:表空间的维护,还应通过对表的定期常规性维护来实现,不要在空间满了才处理:P
|
一共有 0 条评论