oracle 表空間的設定與管理

2021-08-13 08:31:22 字數 1871 閱讀 6972

1.建立大小為50mb的永久表空間test,禁止自動擴充套件資料檔案

create tablespace test

logging

datafile 'e:\orc\test01.dbf' size 50m

reuse autoextend off;

2.建立表永久空間data,允許自動擴充套件資料檔案

create tablespace data 

logging

datafile 'e:\orc\data01.dbf' size 50m

reuse autoextend on next 10m maxsize 200m

extent management local;

3.建立乙個臨時表空間hrtemp1,為了避免臨時空間頻繁分配與**時產生大量碎片,臨時表空間的區只能採用自動分配方式。

create temporary tablespace hrtemp1

tempfile 'e:\orc\hrtemp1.dbf' size 20m;

4.建立乙個撤銷表空間hrund01

create undo tablespace hrund01

datafile 'e:\orc\hrund01_1.dbf' size 20m;

5.將資料庫test表空間的資料檔案test01.dbf大小重置為10m

alter database datafile 

'e:\orc\test01.dbf' resize 10m;

6.通過alter tablespace命令把乙個新的資料檔案新增到data表空間,並指定了autoextend on和maxsize 300m

alter tablespace data 

add datafile 'e:\orc\data02.dbf' size 50m

reuse autoextend on next 50m maxsize 500m;

7.通過alter tablespace命令該表表空間中資料檔案的位置(或名字)

alter tablespace data offline normal;

alter tablespace data rename datafile

'e:\orc\data02.dbf'

to 'e:\orc\ldj\data02n.dbf';

alter tablespace data online;

因為更改檔案的位置,需要手動複製,但是,資料庫會認為這個資料檔案遭到破壞了

因此需要使用這條語句來

recover datafile 'e:\orc\ldj\data02n.dbf';

完成介質恢復,最後才能讓該錶空間變成聯機,不然,資料庫就會出問題

8.刪除表空間data及其對應的資料檔案

drop tablespace data 

including contents and datafiles;

9.檢視當前oracle使用者表空間

select tablespace_name from dba_tablespaces;

10.檢視當前oracle使用者表空間檔案所在位置

select file_name , tablespace_name from dba_data_files;

oracle表空間的空間管理

表空間 tablespace 為資料庫提供使用空間的邏輯結構,其對應物理結構是資料檔案,乙個表空間可以包含多個資料檔案.本地管理表空間 locally managed tablespace簡稱lmt 8i以後出現的一種新的表空間的管理模式,通過本地位圖來管理表空間的空間使用。字典管理表空間 dict...

oracle表空間管理與維護

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

Oracle 表空間的建立與管理

oracle資料庫建立之後有一些預設的表空間隨之被建立,查詢資料字典 dba data files 可以得到資料庫當前的所有表空間資訊。select from v tablespace select tablespace name,file name,bytes 1024 1024 as size ...