oracle表空間與資料檔案日常管理

2021-09-21 09:04:20 字數 2283 閱讀 1871

一.表空間的建立

1.建立普通表空間指定初始大小,自動擴充套件,最大大小:

(oracle允許的單個smallfile資料檔案最大大小為 4194302*blocksize,單個bigfile資料檔案最大可達到(32-128)tb)

(預設建立表空間為標準的8k資料塊,smallfile表空間)

create tablespace t1 datafile '/u01/oracle/product/oradata/orcl/t1.dbf' size 10m autoextend on next 5m maxsize 100m;

2.建立非標準塊大小的表空間:

alter system set db_16k_cache_size=100m scope=spfile;

shutdown immediate;

startup;

create tablespace t2 datafile '/u01/oracle/product/oradata/orcl/t2.dbf' size 10m blocksize 16k;

3.建立大檔案表空間(大檔案表空間只允許有乙個資料檔案):

create bigfile tablespace t3 datafile '/u01/oracle/product/oradata/orcl/t3.dbf' size 10m ;

二.修改表空間(如果修改臨時表空間,注意將語句中的datafile改為tempfile):

1.在表空間中新增資料檔案:

alter tablespace t1 add datafile '/u01/oracle/product/oradata/orcl/t11.dbf' size 1m;

2.在表空間中刪除資料檔案:

alter tablespace t1 drop datafile '/u01/oracle/product/oradata/orcl/t11.dbf';

3.修改指定資料檔案的大小

alter database datafile  '/u01/oracle/product/oradata/orcl/t1.dbf' resize 1m;

三。表空間與資料檔案的offline與online

1.表空間的離線與聯機

alter tablespace t1 offline;

alter tablespace t1 online;

2.資料檔案的離線與聯機(資料檔案的離線與聯機需要使用歸檔模式,資料檔案離線後一定要執行資料檔案介質恢復,否則會報錯)

shutdown immediate;

startup mount;

alter database archivelog;

alter database open;

alter database datafile '/u01/oracle/product/oradata/orcl/t1.dbf' offline;

recover datafile 5;

alter database datafile '/u01/oracle/product/oradata/orcl/t1.dbf' online;

四。表空間改名

alter tablespace t1 rename to t4;

五.表空間刪除

1。正常刪除表空間,不刪除資料檔案:

drop tablespace t4 ;

2.刪除表空間同時刪除所有相關資料檔案;

drop tablespace t2 including contents and datafiles;

六。使用已經存在但未使用的資料檔案建立表空間:

sql> create tablespace t1 datafile '/u01/oracle/product/oradata/orcl/t1.dbf' size 10m;

create tablespace t1 datafile '/u01/oracle/product/oradata/orcl/t1.dbf' size 10m

*error at line 1:

ora-01119: error in creating database file

'/u01/oracle/product/oradata/orcl/t1.dbf'

ora-27038: created file already exists

additional information: 1

sql> create tablespace t1 datafile '/u01/oracle/product/oradata/orcl/t1.dbf' reuse;

tablespace created.

Oracle表空間與資料檔案

1.oracle資料庫邏輯結構包含哪些東西?1 表空間 a.乙個oracle資料庫邏輯上分為更小的邏輯區域叫做表空間 b.乙個表空間同時只屬於乙個資料庫 c.每個表空間由乙個或多個系統檔案組成,叫做資料檔案datafile d.乙個表空間可以有1個或多個段組成 e.當資料庫執行時表空間可以是onli...

Oracle表空間與資料檔案

1.oracle資料庫邏輯結構包含哪些東西?1 表空間 a.乙個oracle資料庫邏輯上分為更小的邏輯區域叫做表空間 b.乙個表空間同時只屬於乙個資料庫 c.每個表空間由乙個或多個系統檔案組成,叫做資料檔案datafile d.乙個表空間可以有1個或多個段組成 e.當資料庫執行時表空間可以是onli...

oracle管理表空間與資料檔案

檢視表空間使用情況 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 b...