如何扩展Oracle表空间

一次,我接到一個朋友的詢問。程式出現了錯誤的提示訊息。ora0163: 表 esps_2010.tbpaymentlimit 无法通过 210 (在表空间esps_2008)扩展。接下來,程式就出現了蠻多莫名的問題。很多流程都無法繼續。借助的工具是P/L SQL 即便在這裏面用SQL逕行作業。

看來僅需擴充表空間的即可解決。

第一步:查看表空間的名字和檔案位置。在SQL欄輸入或貼上下列內容。(不要做任何的修改)

select tablespace_name, file_id, file_name,
     round(bytes/(1024*1024),0) total_space
     from dba_data_files
     order by tablespace_name;


第二步:增大所需表空間的尺寸

alter database datafile '表空間儲存位置'resize 新的尺寸,例如:

alter database datafile 'e:\oracle\oradata\esps_2008.dba'resize 4000m

 BTW:

對於ORACLE數據庫的表空間。除了手動增大所需表空見的尺寸的方法外:您也可使用其他方式來擴展表空見的尺寸。

第一種:增加數據檔案。讓表空間名對應更多的數據檔案

alter tablespace 表空間名稱
     add datafile '新數據檔案的儲存位置' size 新數據檔案的尺寸
,例如:

alter tablespace ESPS_2008
     add datafile 'e:\oracle\oradata\esps_2010.dba' size 1000m

第二種:設定數據檔案自動擴展,以杜絕表空間不足的問題

alter database datafile '數據檔案的儲存位置'
     autoextend on next 下一次擴展數據檔案的尺寸 maxsize 最大可接受的擴展尺寸的極限
,例如:

alter database datafile 'e:\oracle\oradata\esps_2008.dba'
     autoextend on next 100m maxsize 10000m

第三步:查閱設定後的表空間資訊。在SQL欄輸入或貼上下列內容。(不要做任何的修改)

select a.tablespace_name,a.bytes total,b.bytes used, c.bytes free,
     (b.bytes*100)/a.bytes "% used",(c.bytes*100)/a.bytes "% free"
     from sys.sm$ts_avail a,sys.sm$ts_used b,sys.sm$ts_free c
     where a.tablespace_name=b.tablespace_name and a.tablespace_name=c.tablespace_name


你可能感兴趣的:(oracle)