企业如何通过vue小程序开发满足高效运营与合规性需求
310
2023-12-12
Oracle中相对文件号(RFN)和绝对文件号(AFN)的示例分析,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
大家都知道从Oracle8开始,Oracle开始使用“相对文件号”,使原来一个数据库最多只能有1023个文件,扩展为一个表空间最多可以有1023个文件,每个库最多可以有65534个文件。绝对文件号相对于整个数据库是唯一的,每个库最多可以有65534个文件。相对文件号则相对于表空间是唯一的,就是说每个表空间都有自己的相对文件号,每个表空间的最大文件数为1023,相对文件号对于整个数据库来说是不唯一的;查询:SQL> select TS#,FILE#,name from v$datafile order by 1,2;TS# FILE# NAME---------- ---------- ------------------------------------------------------------0 1 /u01/APP/oracle/oradata/DBdb/system01.dbf 1 2 /u01/app/oracle/oradata/DBdb/sysaux01.dbf2 3 /u01/app/oracle/oradata/DBdb/undotbs01.dbf 4 4 /u01/app/oracle/oradata/DBdb/users01.dbf4 7 /u01/app/oracle/oradata/DBdb/users02.dbf4 9 /u01/app/oracle/oradata/DBdb/users03.dbf 6 5 /u01/app/oracle/oradata/DBdb/example01.dbf7 6 /u01/app/oracle/oradata/DBdb/test.dbf 7 8 /u01/app/oracle/oradata/DBdb/test02.DBF9 rows selected.查询v$datafile此视图缺少tmp临时表空间信息,同时包含出tmp临时表空间之外的所有表空间下的所有数据文件SQL> select TS#,FILE#,NAME,BYTES/1024/1024 size_m from v$tempfile; TS# FILE# NAME SIZE_M---------- ---------- ------------------------------------------------------------ ----------
3 1 /u01/app/oracle/oradata/DBdb/temp01.dbf 179
file#绝对文件号 SQL> select TS#,NAME,BIGFILE from v$tablespace order by 1; TS# NAME BIG---------- ------------------------------------------------------------ ---0 SYSTEM NO1 SYSAUX NO 2 UNDOTBS1 NO3 TEMP NO 4 USERS NO6 EXAMPLE NO7 TEST NO7 rows selected.SQL> select TABLESPACE_NAME,FILE_ID,FILE_NAME,BYTES/1024/1024 size_m,STATUS from dba_data_files order by 2;TABLESPACE_NAME FILE_ID FILE_NAME SIZE_M STATUS------------------------------ ---------- ------------------------------------------------------------ ---------- ---------SYSTEM 1 /u01/app/oracle/oradata/DBdb/system01.dbf 2800 AVAILABLESYSAUX 2 /u01/app/oracle/oradata/DBdb/sysaux01.dbf 720 AVAILABLEUNDOTBS1 3 /u01/app/oracle/oradata/DBdb/undotbs01.dbf 2585 AVAILABLEUSERS 4 /u01/app/oracle/oradata/DBdb/users01.dbf 3058.75 AVAILABLEEXAMPLE 5 /u01/app/oracle/oradata/DBdb/example01.dbf 338.75 AVAILABLETEST 6 /u01/app/oracle/oradata/DBdb/test.dbf 10 AVAILABLEUSERS 7 /u01/app/oracle/oradata/DBdb/users02.dbf 10 AVAILABLETEST 8 /u01/app/oracle/oradata/DBdb/test02.DBF 10 AVAILABLEUSERS 9 /u01/app/oracle/oradata/DBdb/users03.dbf 10 AVAILABLE9 rows selected.查询得包含表空间下的所有数据文件SQL> select TABLESPACE_NAME,STATUS,CONTENTS,FORCE_LOGGING,EXTENT_MANAGEMENT,SEGMENT_SPACE_MANAGEMENT,ALLOCATION_TYPE,RETENTION,BIGFILE from dba_tablespaces;TABLESPACE_NAME STATUS CONTENTS FOR EXTENT_MAN SEGMEN ALLOCATIO RETENTION BIG------------------------------ --------- --------- --- ---------- ------ --------- ----------- ---SYSTEM ONLINE PERMANENT NO LOCAL MANUAL SYSTEM NOT APPLY NOSYSAUX ONLINE PERMANENT NO LOCAL AUTO SYSTEM NOT APPLY NOUNDOTBS1 ONLINE UNDO NO LOCAL MANUAL SYSTEM NOGUARANTEE NOTEMP ONLINE TEMPORARY NO LOCAL MANUAL UNIFORM NOT APPLY NOUSERS ONLINE PERMANENT NO LOCAL AUTO SYSTEM NOT APPLY NOEXAMPLE ONLINE PERMANENT NO LOCAL AUTO SYSTEM NOT APPLY NOTEST ONLINE PERMANENT NO LOCAL AUTO SYSTEM NOT APPLY NO7 rows selected.实验开始:SQL> create tablespace test_mf datafile /u01/app/oracle/oradata/DBdb/m1.dbf size 100k reuse;Tablespace created.SQL> alter tablespace test_mf add datafile /u01/app/oracle/oradata/DBdb/m2.dbf size 88k;Tablespace altered.SQL> show parameter db_filesNAME TYPE VALUE------------------------------------ ----------- ------------------------------db_files integer 2000SQL> SQL> begin for i in 3..1025 loopexecute immediatealter tablespace test_mf add datafile /u01/app/oracle/oradata/DBdb/m_ || i || size 88k; end loop; end; / begin*ERROR at line 1:ORA-01686: max # files (1023) reached for the tablespace TEST_MFORA-06512: at line 3SQL> select count(*) from dba_data_files where tablespace_name=TEST_MF; COUNT(*)---------- 1023可以看到表空间TEST_MF的文件数为1023个,最多也只能为1023个。SQL> select count(*) from dba_data_files where tablespace_name=TEST_MF; COUNT(*)----------1023SQL> select ts# from v$tablespace where name=TEST_MF; TS#---------- 9--查询表空间test_mf的相对文件号、绝对文件号:select file_id,relative_fno,TABLESPACE_NAME,FILE_NAME from dba_data_files where tablespace_name=TEST_MF;或者select file#,rfile#,name from v$datafile where ts#=9;SQL> select file#,rfile#,name from v$datafile where ts#=9; FILE# RFILE# NAME---------- ---------- ------------------------------------------------------------ 10 10 /u01/app/oracle/oradata/DBdb/m1.dbf11 11 /u01/app/oracle/oradata/DBdb/m2.dbf 12 12 /u01/app/oracle/oradata/DBdb/m_313 13 /u01/app/oracle/oradata/DBdb/m_4 14 14 /u01/app/oracle/oradata/DBdb/m_5 15 15 /u01/app/oracle/oradata/DBdb/m_616 16 /u01/app/oracle/oradata/DBdb/m_7 17 17 /u01/app/oracle/oradata/DBdb/m_818 18 /u01/app/oracle/oradata/DBdb/m_9省略.................................................................... FILE# RFILE# NAME---------- ---------- ------------------------------------------------------------ 1011 1011 /u01/app/oracle/oradata/DBdb/m_10021012 1012 /u01/app/oracle/oradata/DBdb/m_1003 1013 1013 /u01/app/oracle/oradata/DBdb/m_10041014 1014 /u01/app/oracle/oradata/DBdb/m_1005 1015 1015 /u01/app/oracle/oradata/DBdb/m_10061016 1016 /u01/app/oracle/oradata/DBdb/m_1007 1017 1017 /u01/app/oracle/oradata/DBdb/m_10081018 1018 /u01/app/oracle/oradata/DBdb/m_1009 1019 1019 /u01/app/oracle/oradata/DBdb/m_10101020 1020 /u01/app/oracle/oradata/DBdb/m_1011 1021 1021 /u01/app/oracle/oradata/DBdb/m_1012 FILE# RFILE# NAME---------- ---------- ------------------------------------------------------------1022 1022 /u01/app/oracle/oradata/DBdb/m_1013 1023 1023 /u01/app/oracle/oradata/DBdb/m_10141024 1 /u01/app/oracle/oradata/DBdb/m_1015 1025 2 /u01/app/oracle/oradata/DBdb/m_10161026 3 /u01/app/oracle/oradata/DBdb/m_1017 1027 4 /u01/app/oracle/oradata/DBdb/m_10181028 5 /u01/app/oracle/oradata/DBdb/m_1019 1029 6 /u01/app/oracle/oradata/DBdb/m_10201030 7 /u01/app/oracle/oradata/DBdb/m_1021 1031 8 /u01/app/oracle/oradata/DBdb/m_10221032 9 /u01/app/oracle/oradata/DBdb/m_10231023 rows selected.SQL> 从上面的数据可以看出,当绝对文件号小于等于1023,相对文件号与绝对文件号一样。相对文件号大于1023之后,又从1开始循环。SQL> create tablespace test_lf datafile /u01/app/oracle/oradata/DBdb/TEST_LF.dbf size 1m;Tablespace created.SQL> select ts# from v$tablespace where name=TEST_LF; TS#---------- 10SQL> select file#,rfile#,name from v$datafile where ts#=10; FILE# RFILE# NAME---------- ---------- ------------------------------------------------------------1033 10 /u01/app/oracle/oradata/DBdb/TEST_LF.dbf从上面的数据可以看出,一个表空间的数据文件,其相对文件号并不是从1开始的,而依然是从上一个用过的最后一个相对文件号继续,及file#号从上面的1032增加到1033,而RFILE#从9增加到10。--接着增加新表空间ORASQL> create tablespace ORA datafile /u01/app/oracle/oradata/DBdb/ora.dbf size 1m;Tablespace created.SQL> SQL> alter tablespace ORA add datafile /u01/app/oracle/oradata/DBdb/ora02.dbf size 1m;Tablespace altered.SQL> select file_id,relative_fno,TABLESPACE_NAME,FILE_NAME from dba_data_files where tablespace_name=ORA;FILE_ID RELATIVE_FNO TABLESPACE_NAME FILE_NAME---------- ------------ ------------------------------ ------------------------------------------------------------1034 11 ORA /u01/app/oracle/oradata/DBdb/ora.dbf 1035 12 ORA /u01/app/oracle/oradata/DBdb/ora02.dbf从上查询得,FILE_ID绝对文件号以创建表空间或给表空间添加数据文件的形式递进增加,而RELATIVE_FNO(rfile#)相对文件号相对于表空间而言,一个表空间的数据文件熟练小于等于1023个。--接着查询SQL> select OBJ#,OWNER# from obj$ where name=EMP; OBJ# OWNER#---------- ---------- 87108 83SQL> select object_id from dba_objects where OWNER=SCOTT and object_name=EMP and object_type=TABLE;OBJECT_ID---------- 87108SQL> select obj#,dataobj#,ts#,file# from tab$ where obj#=87108;OBJ# DATAOBJ# TS# FILE#---------- ---------- ---------- ---------- 87108 87108 4 4SQL> select SEGMENT_NAME,HEADER_FILE,HEADER_BLOCK,RELATIVE_FNO,TABLESPACE_NAME from dba_segments where SEGMENT_NAME=EMP and SEGMENT_TYPE=TABLE;
SEGMENT_NAME HEADER_FILE HEADER_BLOCK RELATIVE_FNO TABLESPACE_NAME
--------------- ----------- ------------ ------------ ------------------------------
EMP 4 146 4 USERS
在DBA_SEGMENTS视图里面,可以查到段头的相对文件号和绝对文件号。(这个视图最终是从file$、seg$等字典表里面取得数据)看完上述内容,你们掌握Oracle中相对文件号(RFN)和绝对文件号(AFN)的示例分析的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~