SELECT D.TABLESPACE_NAME,SPACE "SUM_SPACE(M)",BLOCKS SUM_BLOCKS,
USED_SPACE "USED_SPACE(M)",ROUND(NVL(USED_SPACE,0)/SPACE*100,2) "USED_RATE(%)",
NVL(FREE_SPACE,0) "FREE_SPACE(M)"
FROM
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2) SPACE,SUM(BLOCKS) BLOCKS
FROM DBA_TEMP_FILES
GROUP BY TABLESPACE_NAME) D,
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES_USED)/(1024*1024),2) USED_SPACE,
ROUND(SUM(BYTES_FREE)/(1024*1024),2) FREE_SPACE
FROM V$TEMP_SPACE_HEADER
GROUP BY TABLESPACE_NAME) F
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
当通过ORACLE中的create table ... as select 语句创建一张新表时,新表的数据量为比较大,如10亿,这时SQL*Plus很可能就会提示“ORA-01653: ...”错误信息。这个错伍李误信息暗示表空间大小不够,需要为启指表空间增加数据文件。
分析:
1. 查询表空间剩余字节大小
SELECT TABLESPACE_NAME, SUM(BYTES)/1024/1024 AS "FREE SPACE(M)"
FROM DBA_FREE_SPACE
WHERE TABLESPACE_NAME = '&tablespace_name'
GROUP BY TABLESPACE_NAME;
注:如果是临时表空间,请查询DBA_TEMP_FREE_SPACE
SELECT TABLESPACE_NAME, FREE_SPACE/1024/1024 AS "FREE SPACE(M)"
FROM DBA_TEMP_FREE_SPACE
WHERE TABLESPACE_NAME = '&tablespace_name';
2. 如果不知道表空悄橘配间数据文件目录规划,可以先查询出表空间所有数据文件
SELECT TABLESPACE_NAME, FILE_ID, FILE_NAME, BYTES/1024/1024 AS "BYTES(M)"
FROM DBA_DATA_FILES
WHERE TABLESPACE_NAME = '&tablespace_name';
注:如果是临时表空间,请查询DBA_TEMP_FILES
SELECT TABLESPACE_NAME, FILE_ID, FILE_NAME, BYTES/1024/1024 AS "SPACE(M)"
FROM DBA_TEMP_FILES
WHERE TABLESPACE_NAME = '&tablespace_name';
3. 为空间不足的表空间增加数据文件
ALTER TABLESPACE &tablespace_name ADD DATAFILE '&datafile_name' SIZE 2G;
注:如果要为临时表空间扩容,使用下面的语句
ALTER TABLESPACE &tablespace_name ADD TEMPFILE '&datafile_name' SIZE 2G;
当通过ORACLE中的create table ... as select 语句创建一张新表时,新表的数据量为比较大,如10亿,这时SQL*Plus很可能就会提示“ORA-01653: ...”错误信息。这个错误冲袜宽信息暗示表空间大小不够,需要为表空间增加数据文件。 分析: 1. 查询表空间剩余字节大小 SELECT TABLESPACE_NAME, SUM(BYTES)/好盯1024/1024 AS FREE SPACE(M) FROM DBA_FREE_SPACE WHERE TABLESPACE_NAME = '&tablespace_name' GROUP BY TABLESPACE_NAME; 注:如果是临时表空间,请查询DBA_TEMP_FREE_SPACE SELECT TABLESPACE_NAME, FREE_SPACE/1024/1024 AS FREE SPACE(M) FROM DBA_TEMP_FREE_SPACE WHERE TABLESPACE_NAME = '&散亮tablespace_name'; 2. 如果不知道表空间数据文件目录规划,可以先查询出表空间所有数据文件 SELECT TABLESPACE_NAME, FILE_ID, FILE_NAME, BYTES/1024/1024 AS BYTES(M) FROM DBA_DATA_FILES WHERE TABLESPACE_NAME = '&tablespace_name'; 注:如果是临时表空间,请查询DBA_TEMP_FILES SELECT TABLESPACE_NAME, FILE_ID, FILE_NAME, BYTES/1024/1024 AS SPACE(M) FROM DBA_TEMP_FILES WHERE TABLESPACE_NAME = '&tablespace_name'; 3. 为空间不足的表空间增加数据文件 ALTER TABLESPACE &tablespace_name ADD DATAFILE '&datafile_name' SIZE 2G; 注:如果要为临时表空间扩容,使用下面的语句