oracle管理表空間與資料檔案

2021-05-23 20:34:30 字數 1987 閱讀 4820

--檢視表空間使用情況

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

--調整資料檔案大小

alter database datafile 'd:/pam/pam_base1.dbf' resize 5000m;

--修改檔案自增長情況

alter database datafile '/u07/oracle/oradata/train/****.dbf'autoextend on next 100m maxsize unlimited;

----修改表空間自增長情況

alter tablespace ** autoextend on next 100m maxsize unlimited;

--增加資料檔案

alter tablespace 表空間名 add datafile

'' --路徑

size ???m --大小

--重建temp表空間

create temporary tablespace temp2 tempfile 'e:/oracle/product/10.2.0/oradata/orcl/temp02.dbf' size 4000m reuse autoextend on next 100m maxsize unlimited; --建立中轉臨時表空間      

alter database default temporary tablespace temp2; --改變預設臨時表空間 為剛剛建立的新臨時表空間temp2      

drop tablespace temp including contents and datafiles;--刪除原來臨時表空間      

create temporary tablespace temp tempfile 'e:/oracle/product/10.2.0/oradata/orcl/temp01.dbf' size 7000m reuse autoextend on next 100m maxsize unlimited; --重新建立臨時表空間      

alter database default temporary tablespace temp; --重置預設臨時表空間為新建的temp表空間      

drop tablespace temp2 including contents and datafiles;--刪除中轉用臨時表空間      

alter user src_collection temporary tablespace temp; --重新指定使用者表空間為重建的臨時表空間

Oracle學習日曆(七) 管理表空間和資料檔案

介紹 表空間是資料庫的邏輯組成部分。從物理上講,資料庫資料存放在資料檔案中 從邏輯上講,資料庫則是存放在表空間中,表空間由乙個或多個資料檔案組成。表存放到資料檔案中,資料檔案是存放在表空間中的。資料庫的邏輯結構 介紹noracle中邏輯結構包括表空間 段 區和塊。說明一下資料庫由表空間構成,而表空間...

oracle表空間管理與維護

系統中必須的表空間 system sysaux temp undo 表空間的分類 永久表空間 存放永久性資料,如表,索引等。臨時表空間 不能存放永久性物件,用於儲存資料庫排序,分組時產生的臨時資料。undo表空間 儲存資料修改前的鏡象。select tablespace name,檢視表空間的名字及...

Oracle 表空間管理

一 建立表空間f create tablespace mytablespace datafile 建立乙個名為mytablesapce的表空間 path filename1.dbf size 2048m autoextend off,指明資料檔案在存放地點,並關閉檔案的自動擴充套件功能,如果開啟了這...