您好,登錄后才能下訂單哦!
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;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。