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

來源:互聯網
上載者:User

一.資料表空間的建立
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.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.