白天和黑夜只交替没交换无法想像对方的世界
分类: oracle
2013-06-19 16:07:12
前几天roger 的blog 更新了一篇文章,是dbms_rowid包的定义部分,oracle 的包的都是用wrap 进行加密的。itpub上有人研究了unwrap,也公布了一些代码,可以实现unwrap。
关于wrap和unwrap,参考我的blog:
oracle wrap 和 unwrap( 加密与解密) 说明
http://blog.csdn.net/tianlesoftware/article/details/6698535
rowid在db 维护中用的也是比较多。 了解rowid 的相关函数,有助于工作。
oracle rowid 介绍
http://blog.csdn.net/tianlesoftware/article/details/5020718
roger贴的那部分没有只有代码,没有注释,所以这里用toad 把注释部分也拉出来了。贴一下。也可以直接用sql 查看:
sql>select text from dba_source where name='dbms_rowid';
/* formatted on2011/8/18 11:26:49 (qp5 v5.163.1008.3004) */
create or replace package sys.dbms_rowid
is
------------
-- overview
--
-- this package provides procedures to createrowids and to interpret
-- their contents
-- security
--
-- the execution privilege is granted to public.procedures in this
-- package run under the caller security.
----------------------------
----------------------------
-- rowid types:
--
-- restricted - restricted rowid
--
-- extended - extended rowid
--
rowid_type_restricted constant integer := 0;
rowid_type_extended constant integer := 1;
-- rowid verification results:
--
-- valid - valid rowid
--
-- invalid - invalid rowid
--
rowid_is_valid constant integer := 0;
rowid_is_invalid constant integer := 1;
-- object types:
--
-- undefined - object number not defined (forrestricted rowids)
--
rowid_object_undefined constant integer := 0;
-- rowid conversion types:
--
-- internal - convert to/from column of rowidtype
--
-- external - convert to/from string format
--
rowid_convert_internal constant integer := 0;
rowid_convert_external constant integer := 1;
-- exceptions:
--
--rowid_invalid - invalid rowid format
--
--rowid_bad_block - block is beyond end of file
--
rowid_invalid exception;
pragma exception_init (rowid_invalid, -1410);
rowid_bad_block exception;
pragma exception_init (rowid_bad_block, -28516);
-- procedures and functions:
--
--
--rowid_create constructs a rowid from its constituents:
--
--rowid_type - type (restricted/extended)
--object_number - data object number (rowid_object_undefined for restricted)
--relative_fno - relative file number
--block_number - block number in this file
--file_number - file number in this block
--
function rowid_create (rowid_type in number,
object_number in number,
relative_fno in number,
block_number in number,
row_number in number)
return rowid;
pragma restrict_references (rowid_create, wnds, rnds, wnps, rnps);
--
--rowid_info breaks rowid into its components and returns them:
--
--rowid_in - rowid to be interpreted
--rowid_type - type (restricted/extended)
--object_number - data object number (rowid_object_undefined for restricted)
--relative_fno - relative file number
--block_number - block number in this file
-- file_number - file number in this block
--ts_type_in - type of tablespace which this row belongs to
-- 'bigfile' indicates bigfiletablespace
-- 'smallfile' indicates smallfile(traditional pre-10i) ts.
-- note: these two are the onlyallowed values for this param
--
procedure rowid_info (rowid_in in rowid,
rowid_type out number,
object_number out number,
relative_fno out number,
block_number out number,
row_number out number,
ts_type_in in varchar2 default 'smallfile');
pragma restrict_references (rowid_info, wnds, rnds, wnps, rnps);
--
--rowid_type returns the type of a rowid (restricted/extended_nopart,..)
--
--row_id - rowid to be interpreted
--
function rowid_type (row_idin rowid)
return number;
pragma restrict_references (rowid_type, wnds, rnds, wnps, rnps);
--
--rowid_object extracts the data object number from a rowid.
--rowid_object_undefined is returned for restricted rowids.
--
--row_id - rowid to be interpreted
--
function rowid_object (row_idin rowid)
return number;
pragma restrict_references (rowid_object, wnds, rnds, wnps, rnps);
--
--rowid_relative_fno extracts the relative file number from a rowid.
--
--row_id - rowid to be interpreted
--ts_type_in - type of tablespace which this row belongs to
--
function rowid_relative_fno (row_id in rowid,
ts_type_in in varchar2 default 'smallfile')
return number;
pragma restrict_references (rowid_relative_fno, wnds, rnds, wnps, rnps);
--
--rowid_block_number extracts the block number from a rowid.
--
--row_id - rowid to be interpreted
--ts_type_in - type of tablespace which this row belongs to
--
--
function rowid_block_number (row_id in rowid,
ts_type_in in varchar2 default 'smallfile')
return number;
pragma restrict_references (rowid_block_number, wnds, rnds, wnps, rnps);
--
--rowid_row_number extracts the row number from a rowid.
--
--row_id - rowid to be interpreted
--
function rowid_row_number (row_id in rowid)
return number;
pragma restrict_references (rowid_row_number, wnds, rnds, wnps, rnps);
--
--rowid_to_absolute_fno extracts the relative file number from a rowid,
--which addresses a row in a given table
--
--row_id - rowid to be interpreted
--
--schema_name - name of the schema which contains the table
--
--object_name - table name
--
function rowid_to_absolute_fno (row_id in rowid,
schema_name in varchar2,
object_name in varchar2)
return number;
pragma restrict_references (rowid_to_absolute_fno, wnds, wnps, rnps);
--
--rowid_to_extended translates the restricted rowid which addresses
-- arow in a given table to the extended format. later, it may be removed
--from this package into a different place
--
--old_rowid - rowid to be converted
--
--schema_name - name of the schema which contains the table (optional)
--
--object_name - table name (optional)
--
--conversion_type - rowid_convert_internal/external_convert_external
-- (whether old_rowid wasstored in a column of rowid
-- type, or the characterstring)
--
function rowid_to_extended (old_rowid in rowid,
schema_name in varchar2,
object_name in varchar2,
conversion_type in integer)
return rowid;
pragma restrict_references (rowid_to_extended, wnds, wnps, rnps);
--
--rowid_to_restricted translates the extnded rowid into a restricted format
--
--old_rowid - rowid to be converted
--
--conversion_type - internal/external (in)
--
--conversion_type - rowid_convert_internal/external_convert_external
-- (whetherreturned rowid will be stored in a column of
-- rowid type, or thecharacter string)
--
function rowid_to_restricted (old_rowid in rowid,
conversion_type in integer)
return rowid;
pragma restrict_references (rowid_to_restricted, wnds, rnds, wnps, rnps);
--
--rowid_verify verifies the rowid. it returns rowid_valid or rowid_invalid
--value depending on whether a given rowid is valid or not.
--
--rowid_in - rowid to be verified
--
--schema_name - name of the schema which contains the table
--
--object_name - table name
--
--conversion_type - rowid_convert_internal/external_convert_external
-- (whether old_rowid wasstored in a column of rowid
-- type, or the characterstring)
--
function rowid_verify (rowid_in in rowid,
schema_name in varchar2,
object_name in varchar2,
conversion_type in integer)
return number;
pragma restrict_references (rowid_verify, wnds, wnps, rnps);
end;
/
-------------------------------------------------------------------------------------------------------
blog: http://blog.csdn.net/tianlesoftware
weibo:
email: dvd.dba@gmail.com
dba1 群:62697716(满); dba2 群:62697977(满) dba3 群:62697850(满)
dba 超级群:63306533(满); dba4 群: 83829929(满) dba5群: 142216823(满)
dba6 群:158654907(满) 聊天 群:40132017(满) 聊天2群:69087192(满)
--加群需要在备注说明oracle表空间和数据文件的关系,否则拒绝申请