Oracle 10g bigfile表空间简介

  1. Oracle 10g bigfile表空间简介  
  2.   
  3.    
  4. 01. A Bigfile 表空间包含一个非常大的数据文件  
  5.   
  6. 02. SMALLFILE表空间和BIGFILE表空间可以在同一个数据库共存  
  7.   
  8.   
  9. 1.创建一个bigfile表空间  
  10.   
  11.   
  12.     SQL> CREATE BIGFILE TABLESPACE  big01    
  13.          datafile '/oracle/oradata/orcl/big01.dbf' size 50M;  
  14.   
  15. Tablespace created.  
  16.   
  17. 1.2 查看数据库所有表空间bigfile属性,BIG01为bigfile表空间  
  18.   
  19. SQL> select TABLESPACE_NAME, BIGFILE from DBA_TABLESPACES;  
  20.   
  21. TABLESPACE_NAME                BIGFILE  
  22. ------------------------------ --------  
  23. SYSTEM                         NO  
  24. UNDOTBS1                       NO  
  25. SYSAUX                         NO  
  26. TEMP                           NO  
  27. USERS                          NO  
  28. TEST                           NO  
  29. BIG01                          YES  
  30.   
  31.     
  32. 1.3 表空间TEST为SMALLFILE表空间,现在做一个测试resize TEST表空间  
  33. SQL> alter tablespace test  resize 20M;  
  34. alter tablespace test  resize 20M  
  35. *  
  36. ERROR at line 1:  
  37. ORA-32773: operation not supported for smallfile tablespace TEST  
  38.   
  39.   
  40. 由此可见small不支持表空间的resize,当然我们可以通过alter database reszie datafile 来实现smallfile表空间某个数据文件的resize  
  41.   
  42.   
  43.   
  44. 2.bigfile表空间文件  
  45.   
  46.   bigfile表空间只能包含一个文件,它可以非常大,我们不能对bigfile表空间增加数据文件  
  47.         
  48. SQL> alter tablespace big01 add  
  49.   2  datafile '/oracle/oradata/orcl/big02.dbf' size 10M;  
  50. alter tablespace big01 add  
  51. *  
  52. ERROR at line 1:  
  53. ORA-32771: cannot add file to bigfile tablespace  
  54.   
  55.   
  56. 3.BIGFILE表空间的寻址  
  57.   
  58.    bigfile表空间的数据文件大小远远大于smallfile的表空间,其优势得益于Oracle 10g新的寻址方案  
  59.   
  60.    一个rowid寻址存储在传统的SMALLFILE表空间中的对象使用其中的12个字节  
  61.      
  62.    例: rowid寻址  
  63.   
  64.         . 相对File# 3个字节, Block#需要6个字节  
  65.   
  66. 相同的rowid寻址在bigfile表空间只需要9个字节,9个字节存储block#在唯一的文件中  
  67.      
  68.             
  69.           bigfile 表空间只有一个数据文件,因此不必需要另外3个字节的相关连file#  
  70.   
  71.    新寻址方案   
  72.   
  73.         允许在一个单独的数据文件里最多4G个的数据块,  
  74.         数据文件大小blocksize 2K的数据文件最大支持8TB,blocksize 32K的数据文件最大支持到128TB  
  75.         
  76.   
  77. 4.bigfile表空间的优势  
  78.   
  79.   只有一个数据文件的表空间更方便管理,因此唯一的表空间就变成了管理单元  
  80.       
  81.     修改表空间的扩展   
  82. SQL> alter tablespace big01 autoextend on;  
  83.   
  84. Tablespace altered.  
  85.   
  86. SQL> alter tablespace big01 autoextend off;  
  87.   
  88. Tablespace altered.  
  89.   
  90.     在线修改bigfile表空间大小  
  91. SQL> alter tablespace big01 resize 2M;  
  92.   
  93. Tablespace altered.  
  94.   
  95.   
  96. smallfile表空间相对灵活性就不如bigfile表空间  
  97.   
  98. SQL> select TABLESPACE_NAME, BIGFILE from DBA_TABLESPACES where TABLESPACE_NAME='TEST';  
  99.   
  100. TABLESPACE_NAME                BIG  
  101. ------------------------------ ---  
  102. TEST                           NO  
  103.   
  104.   
  105. SQL> alter tablespace test  resize 20M;  
  106. alter tablespace test  resize 20M  
  107. *  
  108. ERROR at line 1:  
  109. ORA-32773: operation not supported for smallfile tablespace TEST  
  110.   
  111.   
  112.   
  113. 5.bigfile表空间支持以下存储管理方式   
  114.   
  115.       --> ASM (Automatic Storage Management)   
  116.       --> a logical volume manager supporting striping/RAID  
  117.       --> dynamically extensible logical volumes  
  118.       --> Oracle Managed Files (OMF)  
  119.     
  120.   
  121.   
  122. 6. 修改数据库创建表空间的bigfile类型   
  123.   
  124.   
  125. SQL> select * from database_properties   
  126.           where property_name='DEFAULT_TBS_TYPE';  
  127.   
  128. 当前数据库创建表空间的默认方式是SMALLFILE表空间  
  129.   
  130. PROPERTY_NAME                  PROPERTY_VALUE                           DESCRIPTION  
  131. ------------------------------ ---------------------------------------- ------------------------------  
  132. DEFAULT_TBS_TYPE               SMALLFILE                                Default tablespace type  
  133.   
  134. 更改数据库创建表空间为BIGFILE表空间  
  135. SQL> ALTER DATABASE SET DEFAULT bigfile TABLESPACE;  
  136.   
  137. Database altered.  
  138.   
  139. SQL> CREATE TABLESPACE big02   
  140. datafile '/oracle/oradata/orcl/big02.dbf' size 10M;  
  141.   
  142. Tablespace created.  
  143.   
  144. SQL> select TABLESPACE_NAME, BIGFILE from DBA_TABLESPACES;  
  145.   
  146. TABLESPACE_NAME                BIG  
  147. ------------------------------ ---  
  148. SYSTEM                         NO  
  149. UNDOTBS1                       NO  
  150. SYSAUX                         NO  
  151. TEMP                           NO  
  152. USERS                          NO  
  153. TEST                           NO  
  154. BIG01                          YES  
  155. BIG02                          YES  
  156.   
  157.   
  158.   
  159. 7. bigfile表空间比传统的smallfile表空间的启动,检查点和DBWR的操作更具有性能优势.  
  160.   
  161.   
  162. 查看数据库文件的文件号和相对文件号  
  163. SQL> select file_name, file_id, relative_fno from dba_data_files;  
  164.   
  165.       
  166. FILE_NAME                                                       FILE_ID RELATIVE_FNO  
  167. ------------------------------------------------------------ ---------- ------------  
  168. /oracle/oradata/orcl/big01.dbf                                        8         1024  
  169. /oracle/oradata/orcl/big02.dbf                                        9         1024  
  170. /oracle/oradata/orcl/users01.dbf                                      4            4  
  171. /oracle/oradata/orcl/sysaux01.dbf                                     3            3  
  172. /oracle/oradata/orcl/undotbs01.dbf                                    2            2  
  173. /oracle/oradata/orcl/system01.dbf                                     1            1  
  174. /oracle/oradata/orcl/system02.dbf                                     6            6  
  175. /oracle/oradata/orcl/test02.dbf                                       7            7  
  176. /oracle/oradata/orcl/test.dbf                                         5            5  
  177.   
  178. 注:bigfile 表空间只有一个数据文件,相对文件号为1024  
  179.   
  180.   
  181.   
  182. 8.bigfile 表空间、smallfile表空间  
  183.   
  184. SQL> SELECT TABLESPACE_NAME,bigfile from dba_tablespaces where tablespace_name='TEST';  
  185.   
  186. TABLESPACE_NAME                BIG  
  187. ------------------------------ ---  
  188. TEST                           NO  
  189.   
  190.   
  191. 1- 在smallfile表空间里从表的rowid中获取相对文件号的信息  
  192.    
  193.    
  194.  SQL> create table st0 (c number) tablespace TEST;  
  195.      Table created.  
  196.   
  197. SQL> insert into st0 values (1);  
  198.      1 row created.  
  199.   
  200.        
  201. SQL> select dbms_rowid.rowid_relative_fno(rowid,'SMALLFILE') from st0;  
  202.   
  203. DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID,'SMALLFILE')  
  204. ------------------------------------------------  
  205.                                                5  
  206.                                                  
  207.                                                  
  208.   
  209. 2- 在smallfile表空间里从表的rowid中获取相对文件号的信息 :  
  210.   
  211. SQL> create table bt01 (c number) tablespace big01;  
  212.      Table created.  
  213.   
  214.      SQL> insert into  bt01 values (1);  
  215.      1 row created.  
  216.   
  217.    
  218. SQL> select dbms_rowid.rowid_relative_fno(rowid,'BIGFILE') from bt01;  
  219.   
  220.      DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID,'BIGFILE')  
  221.      ----------------------------------------------  
  222.                                                1024  
  223.   
  224.   
  225. 9.bigfile表空间支持alter table move   
  226.   
  227. 支持smallfile 表空间总的对象move至bigfile 表空间  
  228.   
  229. SQL> select name, bigfile, table_name from dba_tables t, v$tablespace v  
  230.              where table_name='T11' and v.name=t.tablespace_name;  
  231.   
  232. NAME                           BIG TABLE_NAME  
  233. ------------------------------ --- ------------------------------  
  234. USERS                          NO  T11  
  235.   
  236.    
  237. SQL> ALTER TABLE scott.emp MOVE TABLESPACE BIG01;  
  238.   
  239. Table altered.  
  240.   
  241.     
  242. SQL> Select name, bigfile, table_name from dba_tables t, v$tablespace v  
  243.   2            where table_name='T11' and v.name=t.tablespace_name;  
  244.   
  245. NAME                           BIG TABLE_NAME  
  246. ------------------------------ --- ------------------------------  
  247. BIG01                          YES T11  
  248.   
  249.   
  250.    
  251.   
  252. 特性限制  
  253. ------------   
  254. 新特性仅支持   
  255.   
  256.      --> locally managed tablespaces 本地管理表空间  
  257.      --> with ASSM (automatic segment space management) ASSM管理表空间  
原文地址:https://www.cnblogs.com/lxxxx/p/5300775.html