六分鐘學(xué)會(huì)創(chuàng)建Oracle表空間的步驟
經(jīng)過(guò)長(zhǎng)時(shí)間學(xué)習(xí)創(chuàng)建Oracle表空間,于是和大家分享一下,看完本文你肯定有不少收獲,希望本文能教會(huì)你更多東西。
1、先查詢空閑空間
- select tablespace_name,file_id,block_id,bytes,blocks from dba_free_space;
2、增加Oracle表空間
先查詢數(shù)據(jù)文件名稱、大小和路徑的信息,語(yǔ)句如下:
- select tablespace_name,file_id,bytes,file_name from dba_data_files;
3、修改文件大小語(yǔ)句如下
- alter database datafile
- '需要增加的數(shù)據(jù)文件路徑,即上面查詢出來(lái)的路徑
- 'resize 800M;
4、創(chuàng)建Oracle表空間
- create tablespace test
- datafile '/home/app/oracle/oradata/oracle8i/test01.dbf' size 8M
- autoextend on
- next 5M
- maxsize 10M;
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize unlimited
- maxsize unlimited 是大小不受限制
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- extent management local uniform;
- unform表示區(qū)的大小相同,默認(rèn)為1M
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- extent management local uniform size 500K;
- unform size 500K表示區(qū)的大小相同,為500K
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- extent management local autoallocate;
- autoallocate表示區(qū)的大小由隨表的大小自動(dòng)動(dòng)態(tài)改變,大表使用大區(qū)小表使用小區(qū)
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- temporary;
- temporary創(chuàng)建字典管理臨時(shí)表空間
- create temporary tablespace sales
- tempfile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- 創(chuàng)建本地管理臨時(shí)表空間,如果是臨時(shí)表空間,所有語(yǔ)句中的datafile都換為tempfile
- 8i系統(tǒng)默認(rèn)創(chuàng)建字典管理臨時(shí)表空間,要?jiǎng)?chuàng)建本地管理臨時(shí)表空間要加temporary tablespace關(guān)鍵字
- 創(chuàng)建本地管理臨時(shí)表空間時(shí),不得使用atuoallocate參數(shù),系統(tǒng)默認(rèn)創(chuàng)建uniform管理方式
- 為表空間增加數(shù)據(jù)文件:
- alter tablespace sales add
- datafile '/home/app/oracle/oradata/oracle8i/sales02.dbf' size 800M
- autoextend on next 50M
- maxsize 1000M;
創(chuàng)建本地管理臨時(shí)Oracle表空間,如果是臨時(shí)表空間,所有語(yǔ)句中的datafile都換為tempfile8i系統(tǒng)默認(rèn)創(chuàng)建字典管理臨時(shí)表空間,要?jiǎng)?chuàng)建本地管理臨時(shí)表空間要加temporary tablespace關(guān)鍵字創(chuàng)建本地管理臨時(shí)表空間時(shí),不得使用atuoallocate參數(shù),系統(tǒng)默認(rèn)創(chuàng)建uniform管理方式
為表空間增加數(shù)據(jù)文件:
- alter tablespace sales add
- datafile '/home/app/oracle/oradata/oracle8i/sales02.dbf' size 800M
- autoextend on next 50M
- maxsize 1000M;
5、更改自動(dòng)擴(kuò)展屬性:
- alter database datafile
- '/home/app/oracle/oradata/oracle8i/sales01.dbf',
- '/home/app/oracle/oradata/oracle8i/sales02.dbf'
- '/home/app/oracle/oradata/oracle8i/sales01.dbf
- autoextend off;
以上介紹創(chuàng)建Oracle表空間,在這里拿出來(lái)和大家分享一下,希望對(duì)大家有用。
【編輯推薦】