oracle 的rowid是啥意思

来源:互联网 发布:淘宝上外链代发靠谱吗 编辑:程序博客网 时间:2024/05/16 01:46

官网说明

       owid的定义:A globally unique address for a row in a database.

 

       rowid 分为extended rowid 和 restricted rowied.

 

1.1 Restricted ROWID

       Internally, the ROWID is a structure that holds information that the database server needs to access a row.The restricted internal ROWID is 6 bytes on most platforms.

 

Each restricted rowid includes the following data:

       (1)Datafile identifier

       (2)Block identifier

       (3)Row identifier

 

       The restricted ROWID pseudocolumn is returned to client applications in the form of an18-character string with a hexadecimal encoding of the datablock, row, and datafile components of the ROWID.

 

1.2  Extended ROWID

       The extended ROWID datatype includes the data in the restricted rowid plus a data object number. The data object number is an identification number assigned to every database segment.The extended internal ROWID is 10 bytes on most platforms.

       Data in an extended ROWID pseudocolumn is returned to the client application in the form ofan 18-character string (for example, "AAAA8mAALAAAAQkAAA"), which represents a base 64 encoding of the components of the extended ROWID in a four-piece format,OOOOOOFFFBBBBBBRRR.Extended rowids are not available directly. You canuse a supplied package, DBMS_ROWID, to interpret extended rowid contents. The package functions extract and provide information that would be available directly from a restricted rowid as well as information specific to extended rowids.

 

oracle 的rowid是啥意思
---------------------------------------------------------------

rowid是数据库的一个伪列,建立表的时候数据库会自动为每个表建立ROWID列
用来唯一标识一行记录。
rowid是存储每条记录的实际物理地址,对记录的访问是基于ROWID。
---------------------------------------------------------------

每条记录的物理地址,
对数据库中记录行的作快检索方式就是使用rowid来进行查找。
---------------------------------------------------------------

唯一标识一行记录
select rowid,* from 表名
试一下,你就明白了
---------------------------------------------------------------

rowid就象是邮递员送信时要找的信封上的家庭地址一样,每个rowid都不会重复,oracle查找通过它可以更快地查找到数据.
---------------------------------------------------------------

rowid是一个伪列,对应 块号,行号,行的序号..
---------------------------------------------------------------

ROWID 

    For each row in the database, the ROWID pseudocolumn returns a row's 
    address.  ROWID values contain information necessary to locate a 
    row: 

    * which data block in the data file 
    * which row in the data block (first row is 0) 
    * which data file (first file is 1) 

    In most cases, a ROWID value uniquely identifies a row in the 
    database.  However, rows in different tables that are stored 

    together in the same cluster can have the same ROWID. 

    Values of the ROWID pseudocolumn have the datatype ROWID. 

    ROWID values have several important uses: 

    * They are the fastest means of accessing a single row. 
    * They can show you how a table's rows are stored. 
    * They are unique identifiers for rows in a table. 

    A ROWID does not change during the lifetime of its row.  However, 

    you should not use ROWID as a table's primary key.  If you delete 
    and reinsert a row with the Import and Export utilities, for 
    example, its ROWID may change.  If you delete a row, Oracle may 
    reassign its ROWID to a new row inserted later. 

    Although you can use the ROWID pseudocolumn in the SELECT and WHERE 
    clauses of a query, these pseudocolumn values are not actually 
    stored in the database.  You cannot insert, update, or delete a 

    value of the ROWID pseudocolumn. 

EXAMPLE: 

    This statement selects the address of all rows that contain data for 
    employees in department 20: 

    SELECT ROWID, ename 
        FROM emp 
        WHERE deptno = 20 

    ROWID                  ENAME 
    -----------------     ---------- 
    0000000F.0000.0002     SMITH 
    0000000F.0003.0002     JONES 
    0000000F.0007.0002     SCOTT 

    0000000F.000A.0002     ADAMS 
    0000000F.000C.0002     FORD 


---------------------------------------------------------------

Pseudocolumns 

    A pseudocolumn behaves like a table column, but is not actually 
    stored in the table.  You can select from pseudocolumns, but you 
    cannot insert, update, or delete their values.  This section 
    describes these pseudocolumns: 

    * CURRVAL 
    * NEXTVAL 
    * LEVEL 
    * ROWID 
    * ROWNUM 


---------------------------------------------------------------

伪列:
伪列如同数据表的列,但它实际上不存储在表中
你可以从这些伪列中提取值
但你不能将值插入、更新或者删除它们
以下描述了这些伪列:

---------------------------------------------------------------

oracle数据库中美一条记录的唯一标识。