标签:cts class objects title last wing ora file 使用情况
问题背景:
oracle表空间不足报错是比较常见的故障,尤其是没有对剩余表空间做定期巡检的系统;
报错代码如下:
oracle表空间不足错误代码:ORA-01653: unable to extend table ;
解决方式:
1、查看表空间使用率:
1 set linesize 220; 2 set pagesize 500; 3 col tbsn for a40; 4 select total.tablespace_name TBSN, 5 round(total.MB,3) as total_space, 6 case when free.MB is null then 0 7 else round(free.MB,3) 8 end as free_space, 9 case when free.MB is null then 0 10 else round(free.MB,3)/round(total.MB,3)*100 end as free_rate 11 from ( select tablespace_name, sum(bytes/1024/1024) MB from dba_data_files group by tablespace_name ) total, 12 ( select tablespace_name, sum(bytes/1024/1024) MB from dba_free_space group by tablespace_name ) free 13 where total.tablespace_name=free.tablespace_name(+) 14 order by free_rate desc; 15 16
上述代码可以查询中数据库有哪些表空间,总空间大小,剩余空间大小以及使用百分比,可以做到对表空间使用情况的一目了然
2、 查看磁盘那个空间表多,把表空间放在剩余空间比较多的地方(Linux操作系统)
df -h
3、查看表空间数据文件:
一定要确认好路径,和原有的文件路径保持一致
1 set wrap on; 2 set lines 170 3 col file_name for a80 4 select file_id,file_name,bytes/1024/1024 MB from dba_data_files where tablespace_name=upper(‘&tablespace_name‘);
4、如果是RAC环境还要查看asm磁盘剩余空间
1 select group_number,name,total_mb,free_mb from v$asm_diskgroup;
5、添加表空间 (手动条件数据文件)
1 alter tablespace tablespace_name add datafile ‘/xxxx/xxxx/xxxxx_number.dbf‘ size 30g autoextend off;
6、自己写了一个自动编辑增加数据文件的扩容sql ,可以批量生成扩容脚本(不保证百分百成功率,基本都没问题)
1 set linesize 150 pagesize 900 2 SELECT ‘alter tablespace ‘ || TABLESPACE_NAME || ‘ add datafile ‘‘‘ || 3 substr(file_name, 1, regexp_instr(file_name, ‘[[:digit:]]+\.‘) - 1) || 4 TO_CHAR(substr(file_name, 5 regexp_instr(file_name, ‘[[:digit:]]+\.‘), 6 instr(file_name, ‘.‘) - 7 regexp_instr(file_name, ‘[[:digit:]]+\.‘)) + B.RN) || 8 ‘.dbf‘‘ size ‘ || bytes / 1024 / 1024 || ‘m autoextend off;‘ 9 FROM DBA_DATA_FILES, 10 (select rownum rn 11 from dba_objects 12 WHERE ROWNUM <= &number_of_datafile) B ----增加几个数据文件,比如3个 13 WHERE FILE_ID = (SELECT DISTINCT LAST_VALUE(FILE_ID) 14 OVER(ORDER BY to_number(substr(file_name, regexp_instr(file_name, ‘[[:digit:]]+\.‘), instr(file_name, ‘.‘) - regexp_instr(file_name, ‘[[:digit:]]+\.‘))) ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) 15 FROM DBA_DATA_FILES 16 WHERE tablespace_name = ‘&tablespace_name‘); --表空间名称
oracle表空间不足:ORA-01653: unable to extend table
标签:cts class objects title last wing ora file 使用情况
原文地址:https://www.cnblogs.com/yunweiyipai/p/13095951.html