Oracleの表領域にはスモールファイルとビッグファイルの2種類があります。
SQL> create tablespace TBS_SMALL datafile '/data/tbs_small01.dbf' size 100M,
2 '/data/tbs_small02.dbf' size 100M,
3 '/data/tbs_small03.dbf' size 100M;
表領域が作成されました。
例えばスモールファイル表領域の場合、複数のファイルをデータファイルとして表領域を作成します。
SQL> select tablespace_name, sum(bytes)/1024/1024 "size(MB)" from DBA_DATA_FILES
2 where tablespace_name = 'TBS_SMALL'
3 group by tablespace_name;
TABLESPACE_NAME size(MB)
------------------------------ ----------
TBS_SMALL 300
DBA_DATA_FILESビューで表領域のサイズを確認しています。
100MB×3ファイルで300MBです。
alter tablespace TBS_SMALL add datafile '/data/tbs_small04.dbf' size 100M;
SQL> select tablespace_name, sum(bytes)/1024/1024 "size(MB)" from DBA_DATA_FILES
where tablespace_name = 'TBS_SMALL'
3 group by tablespace_name;
TABLESPACE_NAME size(MB)
------------------------------ ----------
TBS_SMALL 400
alter database datafile '/data/tbs_small01.dbf' resize 125M;
alter database datafile '/data/tbs_small02.dbf' resize 125M;
alter database datafile '/data/tbs_small03.dbf' resize 125M;
alter database datafile '/data/tbs_small04.dbf' resize 125M;
TABLESPACE_NAME size(MB)
------------------------------ ----------
TBS_SMALL 500
また、データファイルを追加したり、データファイルのサイズを拡張することで、表領域を拡張することが出来ます。
SQL> create bigfile tablespace TBS_BIG datafile '/data/tbs_big01.dbf' size 100M,
2 '/data/tbs_big02.dbf' size 100M,
3 '/data/tbs_big03.dbf' size 100M;
create bigfile tablespace TBS_BIG datafile '/data/tbs_big01.dbf' size 100M,
*
行1でエラーが発生しました。:
ORA-32774: BIGFILE表領域TBS_BIGに複数のファイルが指定されています
一方、ビッグファイル表領域ではデータファイルを複数指定することが出来ません。
その代わり、32TBというスモールファイル領域より大きなサイズの表領域を作成することが出来ます。
SQL> create bigfile tablespace TBS_BIG datafile '/data/tbs_big.dbf' size 300M;
表領域が作成されました。
300MBの表領域を作成しています。
SQL> alter tablespace TBS_BIG resize 500M;
表領域が変更されました。
サイズ変更もalter tablespaceで行なうことが出来ます。
SQL> create tablespace TBS_SMALL datafile '/data/tbs_small01.dbf' size 100M,
2 '/data/tbs_small02.dbf' size 100M,
3 '/data/tbs_small03.dbf' size 100M;
表領域が作成されました。
例えばスモールファイル表領域の場合、複数のファイルをデータファイルとして表領域を作成します。
SQL> select tablespace_name, sum(bytes)/1024/1024 "size(MB)" from DBA_DATA_FILES
2 where tablespace_name = 'TBS_SMALL'
3 group by tablespace_name;
TABLESPACE_NAME size(MB)
------------------------------ ----------
TBS_SMALL 300
DBA_DATA_FILESビューで表領域のサイズを確認しています。
100MB×3ファイルで300MBです。
alter tablespace TBS_SMALL add datafile '/data/tbs_small04.dbf' size 100M;
SQL> select tablespace_name, sum(bytes)/1024/1024 "size(MB)" from DBA_DATA_FILES
where tablespace_name = 'TBS_SMALL'
3 group by tablespace_name;
TABLESPACE_NAME size(MB)
------------------------------ ----------
TBS_SMALL 400
alter database datafile '/data/tbs_small01.dbf' resize 125M;
alter database datafile '/data/tbs_small02.dbf' resize 125M;
alter database datafile '/data/tbs_small03.dbf' resize 125M;
alter database datafile '/data/tbs_small04.dbf' resize 125M;
TABLESPACE_NAME size(MB)
------------------------------ ----------
TBS_SMALL 500
また、データファイルを追加したり、データファイルのサイズを拡張することで、表領域を拡張することが出来ます。
SQL> create bigfile tablespace TBS_BIG datafile '/data/tbs_big01.dbf' size 100M,
2 '/data/tbs_big02.dbf' size 100M,
3 '/data/tbs_big03.dbf' size 100M;
create bigfile tablespace TBS_BIG datafile '/data/tbs_big01.dbf' size 100M,
*
行1でエラーが発生しました。:
ORA-32774: BIGFILE表領域TBS_BIGに複数のファイルが指定されています
一方、ビッグファイル表領域ではデータファイルを複数指定することが出来ません。
その代わり、32TBというスモールファイル領域より大きなサイズの表領域を作成することが出来ます。
SQL> create bigfile tablespace TBS_BIG datafile '/data/tbs_big.dbf' size 300M;
表領域が作成されました。
300MBの表領域を作成しています。
SQL> alter tablespace TBS_BIG resize 500M;
表領域が変更されました。
サイズ変更もalter tablespaceで行なうことが出来ます。

コメント