|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
你看出了作者的深度?深处半米!当初是冲那么多的大牛给他写序才买的,后来才发现无啥内容,作者也只是才用几年的新手,百花了几十两银子,再次感叹当今社会的虚伪与浮躁
利用dbms_rowid包取得rowid的具体信息
LastUpdated:Sunday,2004-11-0712:46Eygle
Rowid中包括了纪录的具体信息,经由过程dbms_rowid包能够取得这些信息.本文经由过程一个界说自界说函数先容该package的利用.
createorreplacefunctionget_rowid(l_rowidinvarchar2)returnvarchar2isls_my_rowidvarchar2(200);rowid_typenumber;object_numbernumber;relative_fnonumber;block_numbernumber;row_numbernumber;begindbms_rowid.rowid_info(l_rowid,rowid_type,object_number,relative_fno,block_number,row_number);ls_my_rowid:=Object#is:||to_char(object_number)||chr(10)||Relative_fnois:||to_char(relative_fno)||chr(10)||Blocknumberis:||to_char(block_number)||chr(10)||Rownumberis:||to_char(row_number);returnls_my_rowid;end;/
我们看一下其用法:
[oracle@jumpertools]$sqlplusscott/tigerSQL*Plus:Release9.2.0.4.0-ProductiononSunNov712:30:192004Copyright(c)1982,2002,OracleCorporation.Allrightsreserved.Connectedto:Oracle9iEnterpriseEditionRelease9.2.0.4.0-ProductionWiththePartitioningoptionJServerRelease9.2.0.4.0-ProductionSQL>setechoonSQL>@f_get_rowidSQL>createorreplacefunctionget_rowid2(l_rowidinvarchar2)3returnvarchar24is5ls_my_rowidvarchar2(200);6rowid_typenumber;7object_numbernumber;8relative_fnonumber;9block_numbernumber;10row_numbernumber;11begin12dbms_rowid.rowid_info(l_rowid,rowid_type,object_number,relative_fno,block_number,row_number);13ls_my_rowid:=Object#is:||to_char(object_number)||chr(10)||14Relative_fnois:||to_char(relative_fno)||chr(10)||15Blocknumberis:||to_char(block_number)||chr(10)||16Rownumberis:||to_char(row_number);17returnls_my_rowid;18end;19/Functioncreated.SQL>SQL>select*fromdept;DEPTNODNAMELOC-------------------------------------10ACCOUNTINGNEWYORK20RESEARCHDALLAS30SALESCHICAGO40OPERATIONSBOSTONSQL>selectrowid,a.*fromdepta;ROWIDDEPTNODNAMELOC-------------------------------------------------------AAABiPAABAAAFRSAAA10ACCOUNTINGNEWYORKAAABiPAABAAAFRSAAB20RESEARCHDALLASAAABiPAABAAAFRSAAC30SALESCHICAGOAAABiPAABAAAFRSAAD40OPERATIONSBOSTONSQL>colrow_idfora60SQL>selectget_rowid(AAABiPAABAAAFRSAAA)row_idfromdual;ROW_ID------------------------------------------------------------Object#is:6287Relative_fnois:1Blocknumberis:21586Rownumberis:0SQL>selectget_rowid(AAABiPAABAAAFRSAAB)row_idfromdual;ROW_ID------------------------------------------------------------Object#is:6287Relative_fnois:1Blocknumberis:21586Rownumberis:1SQL>
本文作者:
eygle,Oracle手艺存眷者,来自中国最年夜的Oracle手艺论坛itpub.
www.eygle.com是作者的团体站点.你可经由过程Guoqiang.Gai@gmail.com来接洽作者.接待手艺切磋交换和链接互换.
原文出处:
http://www.eygle.com/faq/Use.dbms_rowid.Package.Get.Detail.Of.Rowid.htm
用一个库#bak_database存放这些历史数据。 |
|