ORA-01653: 表 xxxx 無法通過 8192 (在表空間 USERS 中) 擴充套件
Oracle中增加表空間大小的四種方法
1:給表空間增加資料檔案
ALTER TABLESPACE app_data ADD DATAFILE
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP03.DBF’ SIZE 50M;
2:新增資料檔案,並且允許資料檔案自動增長
ALTER TABLESPACE app_data ADD DATAFILE
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP04.DBF’ SIZE 50M
AUTOEXTEND ON NEXT 5M MAXSIZE 100M;
3:允許已存在的資料檔案自動增長
ALTER DATABASE DATAFILE ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP03.DBF’
AUTOEXTEND ON NEXT 5M MAXSIZE 100M;
4:手工改變已存在資料檔案的大小
ALTER DATABASE DATAFILE ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP02.DBF’
RESIZE 100M;
擴充套件表空間的3種方法
1手動增加資料檔案大小
alter database datafile ‘/home/oracle/ts01.dbf’ resize 100m;
2把表空間設定為自動擴充套件
alter database datafile ‘/home/oracle/ts01.dbf’ autoextend on next 5m maxsize unlimited;
3 往表空間增加資料檔案
alter tablespace ts01 add datafile ‘/home/oracle/ts02.dbf’ size 2m;
SQL> SELECT T.TABLESPACE_NAME,D.FILE_NAME,D.AUTOEXTENSIBLE,D.BYTES,D.MAXBYTES,D.STATUS FROM DBA_TABLESPACES T,DBA_DATA_FILES D WHERE T.TABLESPACE_NAME =D.TABLESPACE_NAME ORDER BY TABLESPACE_NAME,FILE_NAME;
TABLESPACE_NAME
------------------------------------------------------------
FILE_NAME
--------------------------------------------------------------------------------
AUTOEX BYTES MAXBYTES STATUS
------ ---------- ---------- ------------------
SYSAUX
/data/app/oracle/oradata/orcl11g/sysaux01.dbf
YES 1017118720 3.4360E+10 AVAILABLE
SYSTEM
/data/app/oracle/oradata/orcl11g/system01.dbf
YES 786432000 3.4360E+10 AVAILABLE
TABLESPACE_NAME
------------------------------------------------------------
FILE_NAME
--------------------------------------------------------------------------------
AUTOEX BYTES MAXBYTES STATUS
------ ---------- ---------- ------------------
UNDOTBS1
/data/app/oracle/oradata/orcl11g/undotbs01.dbf
YES 3523215360 3.4360E+10 AVAILABLE
USERS
/data/app/oracle/oradata/orcl11g/users01.dbf
TABLESPACE_NAME
------------------------------------------------------------
FILE_NAME
--------------------------------------------------------------------------------
AUTOEX BYTES MAXBYTES STATUS
------ ---------- ---------- ------------------
YES 3.4353E+10 3.4360E+10 AVAILABLE
-- 修改自增長方式
SQL> alter database datafile '/data/app/oracle/oradata/orcl11g/users01.dbf' autoextend on next 500m maxsize unlimited;
資料庫已更改。
SQL> alter database datafile '/data/app/oracle/oradata/orcl11g/sysaux01.dbf' autoextend on next 500m maxsize unlimited;
資料庫已更改。
SQL> alter database datafile '/data/app/oracle/oradata/orcl11g/system01.dbf' autoextend on next 500m maxsize unlimited;
資料庫已更改。
SQL> alter database datafile '/data/app/oracle/oradata/orcl11g/undotbs01.dbf' autoextend on next 50m maxsize unlimited;
資料庫已更改。
-----------查看錶空間是否具有自動擴充套件的能力
SQL> SELECT T.TABLESPACE_NAME,D.FILE_NAME,D.AUTOEXTENSIBLE,D.BYTES,D.MAXBYTES,D.STATUS FROM DBA_TABLESPACES T,DBA_DATA_FILES D WHERE T.TABLESPACE_NAME =D.TABLESPACE_NAME ORDER BY TABLESPACE_NAME,FILE_NAME;
SELECT UPPER(F.TABLESPACE_NAME) "表空間名",D.TOT_GROOTTE_MB "表空間大小(M)",D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空間(M)", TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') "使用比", F.TOTAL_BYTES "空閒空間(M)", F.MAX_BYTES "最大塊(M)" FROM (SELECT TABLESPACE_NAME, ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES, ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES FROM SYS.DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) F, (SELECT DD.TABLESPACE_NAME, ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB FROM SYS.DBA_DATA_FILES DD GROUP BY DD.TABLESPACE_NAME) D WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME ORDER BY 4 DESC;
SQL> Select Tablespace_Name,Sum(bytes)/1024/1024 From Dba_Segments Group By Tablespace_Name;
TABLESPACE_NAME
------------------------------------------------------------
SUM(BYTES)/1024/1024
--------------------
SYSAUX
839.6875
UNDOTBS1
2731.5
USERS
32755.25
TABLESPACE_NAME
------------------------------------------------------------
SUM(BYTES)/1024/1024
--------------------
SYSTEM
748.625
SQL> SELECT tablespace_name 表空間,sum(blocks*8192/1000000) 剩餘空間M FROM dba_free_space GROUP BY tablespace_name;
表空間 剩餘空間M
------------------------------------------------------------ ----------
SYSAUX 135.593984
UNDOTBS1 657.98144
USERS 5.24288
SYSTEM .393216
SQL> select b.name,sum(a.bytes/1000000)總空間 from v$datafile a,v$tablespace b where a.ts#=b.ts# group by b.name;
NAME 總空間
------------------------------------------------------------ ----------
SYSAUX 1017.11872
UNDOTBS1 3523.21536
USERS 34352.6605
SYSTEM 786.432
SQL> SELECT SUM(BYTES) FROM DBA_EXTENTS WHERE SEGMENT_NAME = 'WECENJOY';
SUM(BYTES)
------------
2013265920
PS:oracle可管理的最大資料塊為2的22次方個,而根據單個數據塊大小大小的不同,其最大容量也是不同的。對於OLTP應用,資料塊的大小通常為8K,這樣,算下來,單個數據檔案的大小最大為(2^22)*8K=32G.
既使指定“不限制”,其最大空間也是不能超過可管理最大空間的上限的。
修改表空間資料檔案大小為不限制的語句為:
alter database datafile ‘/oradata/orcl/demo01.dbf’ autoextend on maxsize unlimited;
建立表空間資料檔案大小為不限制的語句為:
create tablespace demo2 datafile ‘/oradata/orcl/demo201.dbf’ size 10M autoextend on maxsize unlimited;
所以只能
增加表空間
新增檔案
SQL> alter tablespace SYSTEM add datafile '/data/app/oracle/oradata/orcl11g/system02.dbf' size 30000M autoextend on next 50M maxsize unlimited;
SQL> alter tablespace USERS add datafile '/data/app/oracle/oradata/orcl11g/users02.dbf' size 30000M autoextend on next 50M maxsize unlimited;
注意路徑正確 有許可權寫入
再查表空間 已經新增了
SQL> SELECT tablespace_name 表空間,sum(blocks*8192/1000000) 剩餘空間M FROM dba_free_space GROUP BY tablespace_name;
表空間 剩餘空間M
------------------------------------------------------------ ----------
SYSAUX 135.069696
UNDOTBS1 657.98144
USERS 33648.0174
SYSTEM 31456.6246