關於oracle表空間不足原因及處理方法


  

oracle表空間不足,一般有兩個原因:

          一,原表空間太小,沒有自增長;

          二,表空間已自增長,而且表空間也已足夠大,對於這兩種原因分別有各自的解決辦法。

oracle表空間不足錯誤代碼:ORA-01653: unable to extend table 等;

 

查看表空間使用情況:

  SELECT tbs 表空間名,
  sum(totalM) 總共大小M,
  sum(usedM) 已使用空間M,
  sum(remainedM) 剩余空間M,
  sum(usedM)/sum(totalM)*100 已使用百分比,
  sum(remainedM)/sum(totalM)*100 剩余百分比
  FROM(
  SELECT b.file_id ID,
  b.tablespace_name tbs,
  b.file_name name,
  b.bytes/1024/1024 totalM,
  (b.bytes-sum(nvl(a.bytes,0)))/1024/1024 usedM,
  sum(nvl(a.bytes,0)/1024/1024) remainedM,
  sum(nvl(a.bytes,0)/(b.bytes)*100),
  (100 - (sum(nvl(a.bytes,0))/(b.bytes)*100))
  FROM dba_free_space a,dba_data_files b
  WHERE a.file_id = b.file_id
  GROUP BY b.tablespace_name,b.file_name,b.file_id,b.bytes
  ORDER BY b.tablespace_name
  )
  GROUP BY tbs ;

 

1、查詢當前用戶的所屬表空間

    select * from user_users;

2、增加表空間有兩種方法: 修改數據文件大小, 增加數據文件。

 

   1.語法:修改數據文件大小

  alter tablespace 表空間名稱

  add datafile 表空間存放路徑  size 表空間大小 autoextend on next 增長的大小 maxsize 空間最大值(如果不限制空間最大值就用unlimited)

  例如:

    alter tablespace vgsm
    add datafile 'c:\oracle\product\10.2.0\oradata\vgsm\vgsm_01.dbf'
    size 1024M autoextend on next 50M maxsize unlimited;

 

查詢表空間詳情:

select f.* from dba_data_files f where f.tablespace_name='VGSM'

 

  2.增加數據文件:

  語法:

  alter database

  datafile 表空間文件路徑

 AUTOEXTEND(自動擴展) ON NEXT 表空間滿后增加的大小

例如:

  alter database
 datafile 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\VGSM\VGSM' AUTOEXTEND ON NEXT 200m

查詢表空間詳情:

select f.* from dba_data_files f where f.tablespace_name='VGSM'


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM