摘自:http://www.eygle.com/archives/2007/07/function_rdba_convert.html
1.写了一个简单的函数,用来从RDBA中转换file#和block#出来:
CREATE OR REPLACE FUNCTION getbfno (p_dba IN VARCHAR2)
RETURN VARCHAR2
IS
l_str VARCHAR2 (255) DEFAULT NULL;
l_fno VARCHAR2 (15);
l_bno VARCHAR2 (15);
BEGIN
l_fno :=
DBMS_UTILITY.data_block_address_file (TO_NUMBER (LTRIM (p_dba, '0x'),
'xxxxxxxx'
)
);
l_bno :=
DBMS_UTILITY.data_block_address_block (TO_NUMBER (LTRIM (p_dba, '0x'),
'xxxxxxxx'
)
);
l_str :=
'datafile# is:'
|| l_fno
|| CHR (10)
|| 'datablock is:'
|| l_bno
|| CHR (10)
|| 'dump command:alter system dump datafile '
|| l_fno
|| ' block '
|| l_bno
|| ';';
RETURN l_str;
END;
/
2.现在直接调用这个函数:
SQL> select getbfno('0x1800083') BFNO from dual;
BFNO
------------------------------------------------------------
datafile# is:6
datablock is:131
dump command:alter system dump datafile 6 block 131;
3. 也可以直接查询
SQL> select dbms_utility.data_block_address_file(TO_NUMBER('1800083', 'XXXXXXXX')) file_id,
dbms_utility.data_block_address_block(TO_NUMBER('1800083', 'XXXXXXXX')) block_id from dual; 2
FILE_ID BLOCK_ID
---------- ----------
6 131
注意:这里的值都是16进制的