Oracle 查看表空间、调整数据文件;查看临时表空间,调整临时表数据文件

it2026-03-19  3

--查看表空间使用率的sql语句: select * from (Select a.tablespace_name, to_char(a.bytes / 1024 / 1024, '99,999,999.99') "total_bytes(M)", to_char(b.bytes / 1024 / 1024, '99,999,999.99') "free_bytes(M)", to_char(a.bytes / 1024 / 1024 - b.bytes / 1024 / 1024, '99,999,999.99') "use_bytes(M)", to_char((1 - b.bytes / a.bytes) * 100, '99.99') || '%' use from (select tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name) a, (select tablespace_name, sum(bytes) bytes from dba_free_space group by tablespace_name) b where a.tablespace_name = b.tablespace_name union all select c.tablespace_name, to_char(c.bytes / 1024 / 1024, '99,999,999.99') total_bytes, to_char((c.bytes - d.bytes_used) / 1024 / 1024, '99,999,999.99') free_bytes, to_char(d.bytes_used / 1024 / 1024, '99,999,999.99') use_bytes, to_char(d.bytes_used * 100 / c.bytes, '99.99') || '%' use from (select tablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name) c, (select tablespace_name, sum(bytes_cached) bytes_used from v$temp_extent_pool group by tablespace_name) d where c.tablespace_name = d.tablespace_name) order by tablespace_name; --查看表空间数据文件 select d.file_name, d.tablespace_name, d.autoextensible, to_char(d.BYTES / 1024 / 1024, '99,999,999.99') bytes from dba_data_files d where d.TABLESPACE_NAME = 'MOBILE_PAFETBS'; --调整数据文件大小 alter database DATAFILE '/oradata/orcl/MOBILE_PAFETBS02.dbf' resize 1024m; --查看普通数据文件是否扩展 select d.file_name,d.tablespace_name,d.autoextensible,d.BYTES from dba_data_files d -- 执行添加临时表空间的数据文件命令:(解决ORA-01652 无法通过128 (在表空间 TEMP中)扩展temp段) ALTER TABLESPACE TBS_QS_AGENT/*表空间名*/ ADD DATAFILE '/oradata/orcl/TBS_QS_AGENT04.dbf'/*新的数据文件*/ SIZE 2G; --查看临时表空间 select * from database_properties where property_name='DEFAULT_TEMP_TABLESPACE'; --查看临时表数据文件(大小、是否自动扩展) select tablespace_name,file_name,bytes/1024/1024 "file_size(M)",autoextensible from dba_temp_files; --将临时数据文件设为自动扩展: alter database tempfile '/oradata/orcl/temp01.dbf' autoextend on next 5m maxsize unlimited; --取消自动扩展 alter database datafile 文件路径 autoextend off alter database tempfile '/oradata/orcl/temp01.dbf' autoextend off; --增大临时文件大小 alter database tempfile '/oradata/orcl/temp01.dbf' resize 6144m;
最新回复(0)