如今是互聯(lián)網(wǎng)大數(shù)據(jù)時代,很多人都知道數(shù)據(jù)庫這個東西,簡單的說就是儲存數(shù)據(jù)的地方。但是數(shù)據(jù)庫分很多種,比較常見的有Oracle數(shù)據(jù)庫,那么Oracle表空間如何創(chuàng)建?其實Oracle表空間的創(chuàng)建非常簡單,如果你想學(xué)只需要抽出6分鐘的時間,即可學(xué)會。創(chuàng)建Oracle表空間首先查詢空閑空間、增加Oracle表空間、修改文件大小語句如下、創(chuàng)建Oracle表空間,最后更改自動擴展屬性。
1、先查詢空閑空間
代碼如下:
select tablespace_name,file_id,block_id,bytes,blocks from dba_free_space;
2、增加Oracle表空間
先查詢數(shù)據(jù)文件名稱、大小和路徑的信息,語句如下:
代碼如下:
select tablespace_name,file_id,bytes,file_name from dba_data_files;
3、修改文件大小語句如下
代碼如下:
alter database datafile
'需要增加的數(shù)據(jù)文件路徑,即上面查詢出來的路徑
'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ū)的大小由隨表的大小自動動態(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)建字典管理臨時表空間
create temporary tablespace sales
tempfile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
autoextend on
next 50M
maxsize 1000M
創(chuàng)建本地管理臨時表空間,如果是臨時表空間,所有語句中的datafile都換為tempfile
8i系統(tǒng)默認(rèn)創(chuàng)建字典管理臨時表空間,要創(chuàng)建本地管理臨時表空間要加temporary tablespace關(guān)鍵字
創(chuàng)建本地管理臨時表空間時,不得使用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)建本地管理臨時Oracle表空間,如果是臨時表空間,所有語句中的datafile都換為tempfile8i系統(tǒng)默認(rèn)創(chuàng)建字典管理臨時表空間,要創(chuàng)建本地管理臨時表空間要加temporary tablespace關(guān)鍵字創(chuàng)建本地管理臨時表空間時,不得使用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、更改自動擴展屬性:
代碼如下:
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;
以上即是關(guān)于Oracle表空間如何創(chuàng)建的全部操作步驟,想了解更多關(guān)于Oracle數(shù)據(jù)庫的信息,請繼續(xù)關(guān)注中培偉業(yè)。