1:表空間大小
select tablespace_name,count(*),sum(blocks),sum(bytes)/1024/1024
from dba_data_files
group by tablespace_name;
2:表空間使用情況
select df.tablespace_name "表空間名",totalspace "總空間m",freespace "剩餘空間m",round((1-freespace/totalspace)*100,2) "使用率%"
from
(select tablespace_name,round(sum(bytes)/1024/1024) totalspace
from dba_data_files
group by tablespace_name) df,
(select tablespace_name,round(sum(bytes)/1024/1024) freespace
from dba_free_space
group by tablespace_name) fs
where df.tablespace_name=fs.tablespace_name;
3:刪除表空間
--select t.name,d.name from v$tablespace t,v$datafile d where t.name='data_host_a' and t.ts#=d.ts#;
--alter tablespace data_host_a offline;
--drop tablespace data_host_a including contents;
4:為這個表空間增加乙個資料檔案
--sql> alter tablespace 表空間名 add datafile '/u1/oradata/userdata_002.ora' size 50m; --unix中
--sql> alter tablespace 表空間名 add datafile 'c:/oradata/userdata_002.ora' size 50m; --windows nt中
5:重新調整資料檔案的大小
--sql> alter database datafile '/u1/oradata/userdata_001.ora' resize 50m; --unix中
--sql> alter database datafile 'c:/oradata/userdata_002.ora' resize 50m; --windows nt中
6:檢視資料庫的大小,和空間使用情況
col tablespace format a20
select b.file_id 檔案id,
b.tablespace_name 表空間,
b.file_name 物理檔名,
b.bytes 總位元組數,
(b.bytes-sum(nvl(a.bytes,0))) 已使用,
sum(nvl(a.bytes,0)) 剩餘,
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
/dba_free_space --表空間剩餘空間狀況
dba_data_files --資料檔案空間占用情況
Oracle 表空間管理
一 建立表空間f create tablespace mytablespace datafile 建立乙個名為mytablesapce的表空間 path filename1.dbf size 2048m autoextend off,指明資料檔案在存放地點,並關閉檔案的自動擴充套件功能,如果開啟了這...
oracle 表空間管理
表空間是資料庫的邏輯組成部分,從物理上講資料庫資料存放在資料檔案中 從邏輯上講,資料庫則是存放在表空間中,表空間是由乙個或者多個資料檔案組成。oracle資料庫邏輯結構組成部分 資料庫是由表空間組成,而表空間又是由段構成,段是由區構成,而區是又oracle資料庫的塊組成這樣的一種結構,這樣可以提高資...
ORACLE 表空間管理
1.create tablespaces sql create tablespace tablespace name datafile c oracle oradata file1.dbf size 100m,sql c oracle oradata file2.dbf size 100m mini...