查询表空间对应数据文件的路径和大小
select file_id , file_name , tablespace_name , bytes/1024/1024/1024 G from dba_data_files where tablespace_name like '&tablespace_name' order by 1;
数据文件查询对应表空间 select t1.name,t2.name from v$tablespace t1,v$datafile t2 where t1.ts#=t2.ts#;
重新设置数据文件大小 alter database datafile '/oracle/app/oradata/orcl/eciq_cdtp_02.dbf' resize 7G ;
查表空间使用率情况(含临时表空间) SELECT d.tablespace_name "Name", d.status "Status", TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99,999,990.90') "Size (M)", TO_CHAR (NVL (a.BYTES - NVL (f.BYTES, 0), 0) / 1024 / 1024, '99999999.99' ) USE, TO_CHAR (NVL ((a.BYTES - NVL (f.BYTES, 0)) / a.BYTES * 100, 0), '990.00' ) "Used %" FROM SYS.dba_tablespaces d, (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) f WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+) AND NOT (d.extent_management LIKE 'LOCAL' AND d.CONTENTS LIKE 'TEMPORARY') UNION ALL SELECT d.tablespace_name "Name", d.status "Status", TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99,999,990.90') "Size (M)", TO_CHAR (NVL (t.BYTES, 0) / 1024 / 1024, '99999999.99') USE, TO_CHAR (NVL (t.BYTES / a.BYTES * 100, 0), '990.00') "Used %" FROM SYS.dba_tablespaces d, (SELECT tablespace_name, SUM (BYTES) BYTES FROM dba_temp_files GROUP BY tablespace_name) a, (SELECT tablespace_name, SUM (bytes_cached) BYTES FROM v$temp_extent_pool GROUP BY tablespace_name) t WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = t.tablespace_name(+) AND d.extent_management LIKE 'LOCAL' AND d.CONTENTS LIKE 'TEMPORARY';
查询表空间数据文件是否为自动扩展 select file_id,file_name,autoextensible from dba_data_files where tablespace_name like '&tablespace' order by 1;
显示表空间的已被使用多少 select tablespace_name,sum(bytes)/1024/1024/1024 G from dba_data_files group by tablespace_name; 显示表空间还有多少没有使用 select tablespace_name,sum(bytes)/1024/1024/1024 GB from dba_free_space group by tablespace_name;