1.查詢表空間使用情況:
sqlplus system/manager@topprod
sql>@q_tbsfree
2.查詢temp使用方法:
sqlplus system/manager@topprod
sql>select
d.tablespace_name tablespace_name
, d.status tablespace_status
, nvl(a.bytes, 0) tablespace_size
, nvl(t.bytes, 0) used
, trunc(nvl(t.bytes / a.bytes * 100, 0)) used_pct
, nvl(s.current_users, 0) current_users
from
sys.dba_tablespaces d
, ( select tablespace_name, sum(bytes) bytes
from dba_temp_files
group by tablespace_name
) a, ( select tablespace_name, sum(bytes_cached) bytes
from v$temp_extent_pool
group by tablespace_name
) t, v$sort_segment s
where
d.tablespace_name = a.tablespace_name(+)
and d.tablespace_name = t.tablespace_name(+)
and d.tablespace_name = s.tablespace_name(+)
and d.extent_management like 'local'
and d.contents like 'temporary';
2.清理temp臨時表空間:(在無使用者連線的狀況下操作,最好在清理之前重啟一下資料庫)
#重啟資料庫
sqlplus '/as sysdba'
sql>shutdown immediate
sql>startup
#建立乙個臨時表空間temp02,用作臨時替換
sql>create temporary tablespace temp02 tempfile '/u2/oradb/oradata/topprod/temp02.dbf' size 10m autoextend on next 10m;
#將系統臨時表空間指向temp02
sql>alter database default temporary tablespace temp02;
#刪除原來的臨時表空間temp
sql>drop tablespace temp including contents and datafiles;
#建立新的臨時表空間temp
sql>create temporary tablespace temp tempfile '/u2/oradb/oradata/topprod/temp01.dbf' size 4096m autoextend on next 100m;
#將系統臨時表空間指回temp
sql>alter database default temporary tablespace temp;
#刪除臨時表空間temp02
sql>drop tablespace temp02 including contents and datafiles;
3.清理undo表空間:(在無使用者連線的狀況下操作,最好在清理之前重啟一下資料庫)
#重啟資料庫
sqlplus '/as sysdba'
sql>shutdown immediate
sql>startup
#建立乙個undo表空間undotbs2,用作臨時替換
sql>create undo tablespace undotbs2 datafile '/u2/oradb/oradata/topprod/undotbs02.dbf' size 10m autoextend on next 10m;
#將系統undo表空間指向undotbs2
sql>alter system set undo_tablespace=undotbs2 scope=both;
#確保所有在undotbs1的undo segment都已offline
sql> select segment_name ,status ,tablespace_name from dba_rollback_segs;
#刪除原來的undo表空間undotbs1
sql>drop tablespace undotbs1 including contents and datafiles;
#建立新的臨時表空間undotbs1
sql>create undo tablespace undotbs1 datafile '/u2/oradb/oradata/topprod/undotbs01.dbf' size 4096m;
#將系統undo表空間指回undotbs1
sql>alter system set undo_tablespace=undotbs1 scope=both;
#刪除undo表空間undotbs2
sql>drop tablespace undotbs2 including contents and datafiles;
3.清理temptabs表空間:
#刪除temptabs表空間
sql>drop tablespace temptabs including contents and datafiles;
#建立temptabs表空間
sql>create tablespace temptabs datafile '/u2/oradb/oradata/topprod/temptabs.dbf' size 4096m autoextend on next 100m;
或者刪除表
select 'drop table '||segment_name ||';' from dba_segments where tablespace_name='temptabs' and segment_name like 'tt%' and segment_name not like '%_file';
4.增加系統表空間:
alter tablespace system add datafile '/u2/oradb/oradata/topprod/system02.dbf' size 2000m autoextend on next 10m;
alter tablespace sysaux add datafile '/u2/oradb/oradata/topprod/sysaux02.dbf' size 2000m autoextend on next 10m;
Oracle空表開關
設定deferred segment creation引數 以下語句可以在cmd裡登入資料庫後執行 檢視引數 show parameter deferred segment creation 設定引數 alter system set deferred segment creation false ...
oracle 匯出空表
資料庫備份 空表不能匯出的問題處理 設定deferred segment creation 引數 設定deferred segment creation 引數為false來禁用 段推遲建立 也就是直接建立segment 無論是空表還是非空表,都分配segment。在sqlplus中,執行如下命令 s...
關於ORACLE清理表空間總結
1.檢視索引和表的初始大小 select bytes 1024 1024 m table size u.from dba segments u where u.owner in clear trade inte ce security order by 1 desc 2.通過上面語句找到占用空間較大...