oracle表空間管理

2022-09-02 19:03:07 字數 1990 閱讀 3434

建立表空間

create tablespace tablespace_name nologging datafile '/data/oradata/data_01.dbf' size 2048m autoextend off ;

增加資料檔案

alter tablespace tablespace_name add datafile '/data/oradata/data_02.dbf' size 2048m autoextend off ;

修改表空間

select file_id from dba_data_files where tablespace_name=;

alter database datafile autoextend on next 10m maxsize 10g;

刪除表空間

drop tablespace tablespace_name including contents and datafiles;

--檢視當前使用者的表占用的空間

select segment_name,sum(bytes)/1024/1024 from user_extents group by segment_name ;

select sum(bytes)/1024/1024 from user_extents ;

---查詢資料庫表空間使用情況

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

bytablespace_name) f,

(select

dd.tablespace_name,

round(sum(dd.bytes) / (1024

*1024), 2

) tot_grootte_mb

from

sys.dba_data_files dd

group

bydd.tablespace_name) d

where d.tablespace_name =

f.tablespace_name

orderby4

desc

檢視某個表空間裡面都有哪些表

select * from dba_tables where tablespace_name='表空間名'

資料檔案被刪除,資料庫啟動時報錯:

ora-01157: cannot identify/lock data file 602 - see dbwr trace file

ora-01110: data file 602: '/oracle/daa.dbf'

處理方法:

1 停資料庫:shutdown abort;

2 mount : startup mount

3 將資料檔案置為離線並drop: alter database datafile '/oracle/daa.dbf' offline drop;

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...