--查看表空间的位置和物理文件
select TABLESPACE_NAME,FILE_ID,FILE_NAME,BYTES/(1024*1024)TOTAL_SPACE from dba_data_files
--修改原有表空间大小
alter database datafile 'D:\DATABASE\CDRDB\PLANT_SERVICE11.DBF' resize 8192m;
alter database datafile 'D:\DATABASE\CDRDB\PLANT_SERVICE12.DBF' resize 8192m;
---扩大表空间
ALTER TABLESPACE UNDOTBS1 ADD DATAFILE
'D:\DATABASE\CDRDB\UNDOTBS02.DBF' SIZE 20480M
AUTOEXTEND ON NEXT 100M MAXSIZE 20480M;
--是否自动增长
SELECT FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE FROM dba_data_files;
--查看表空间信息
SELECT TABLESPACE_NAME "表空间",
To_char(Round(BYTES / 1024, 2), '99990.00')
|| '' "实有",
To_char(Round(FREE / 1024, 2), '99990.00')
|| 'G' "现有",
To_char(Round(( BYTES - FREE ) / 1024, 2), '99990.00')
|| 'G' "使用",
To_char(Round(10000 * USED / BYTES) / 100, '99990.00')
|| '%' "比例"
FROM (SELECT A.TABLESPACE_NAME TABLESPACE_NAME,
Floor(A.BYTES / ( 1024 * 1024 )) BYTES,
Floor(B.FREE / ( 1024 * 1024 )) FREE,
Floor(( A.BYTES - B.FREE ) / ( 1024 * 1024 )) USED
FROM (SELECT TABLESPACE_NAME TABLESPACE_NAME,
Sum(BYTES) BYTES
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) A,
(SELECT TABLESPACE_NAME TABLESPACE_NAME,
Sum(BYTES) FREE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) B
WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME)
--WHERE TABLESPACE_NAME LIKE 'CDR%' --这一句用于指定表空间名称
ORDER BY Floor(10000 * USED / BYTES) DESC;