Chapter 30. DBMS_ROWID

Table of Contents

30.1. Overview
30.2. Procedure
30.2.1. ROWID_INFO
30.3. Functions
30.3.1. ROWID_CREATE
30.3.2. ROWID_SEGMENT
30.3.3. ROWID_BLOCK_NUMBER
30.3.4. ROWID_ROW_NUMBER
30.3.5. ROWID_ABSOLUTE_FNO
30.3.6. ROWID_TO_RELATIVE_FNO

This chapter briefly introduces the DBMS_ROWID package, and describes how to use the procedures and functions of the package.

30.1. Overview

DBMS_ROWID returns information about the ROWID obtained from executing a SQL query or PSM, or creates a ROWID. ROWID includes information related to segments, blocks, absolute files and row numbers.

30.2. Procedure

This section describes the procedure provided by the DBMS_ROWID package.

30.2.1. ROWID_INFO

Exports all information about the ROWID. Since this is a procedure, it cannot be used in a SQL statement.

Details about the ROWID_INFO procedure are as follows:

  • Prototype

    PROCEDURE ROWID_INFO
    (
        rowid_in        IN   ROWID, 
        segment_number  OUT  NUMBER, 
        absolute_fno    OUT  NUMBER,
        block_number    OUT  NUMBER,
        row_number      OUT  NUMBER
    );
  • Parameter

    ParameterDescription
    rowid_inROWID.
    segment_numberSegment number.
    absolute_fnoAbsolute file number.
    block_numberBlock number.
    row_numberRow number.
  • Example

    DBMS_ROWID.ROWID_INFO(rowid_1, sgmt_no, fno, blk_no, row_no);
    DBMS_OUTPUT.PUT_LINE('segment number : ' || sgmt_no);
    DBMS_OUTPUT.PUT_LINE('absolute file number : ' || fno);
    DBMS_OUTPUT.PUT_LINE('block number : ' || blk_no);
    DBMS_OUTPUT.PUT_LINE('row number : ' || row_no);

30.3. Functions

This section describes the functions provided by the DBMS_ROWID package, in alphabetical order.

30.3.1. ROWID_CREATE

Creates the ROWID with the entered information. This function is useful for checking whether a ROWID has been created correctly. The user can try to create a ROWID with random information but this is not meaningful.

Details about the ROWID_CREATE procedure are as follows:

  • Prototype

    FUNCTION ROWID_CREATE
    (
        segment_number  IN   NUMBER, 
        absolute_fno    IN   NUMBER, 
        block_number    IN   NUMBER, 
        row_number      IN   NUMBER
    ) 
    RETURN ROWID;
  • Parameter

    ParameterDescription
    segment_numberSegment number.
    absolute_fnoAbsolute file number.
    block_numberBlock number within the file.
    row_numberRow number within the block.
  • Example

    DBMS_ROWID.ROWID_INFO(rowid_1, sgmt_no, fno, blk_no, row_no);
    my_rowid := DBMS_ROWID.ROWID_CREATE(sgmt_no, fno, blk_no, row_no);
    DBMS_OUTPUT.PUT_LINE(rowid_1 || ' ' || my_rowid);

30.3.2. ROWID_SEGMENT

Extracts and returns the segment number from the given ROWID.

Details about the ROWID_SEGMENT function are as follows:

  • Prototype

    FUNCTION ROWID_SEGMENT
    (
        row_id   IN   ROWID
    ) 
    RETURN NUMBER;
  • Parameter

    ParameterDescription
    row_idROWID.
  • Example

    SELECT dbms_rowid.rowid_segment(rowid)
    FROM table;

30.3.3. ROWID_BLOCK_NUMBER

Extracts and returns the block number in the file for the given ROWID.

Details about the ROWID_BLOCK_NUMBER function are as follows:

  • Prototype

    FUNCTION ROWID_BLOCK_NUMBER
    (
        row_id   IN   ROWID
    ) 
    RETURN NUMBER;
  • Parameter

    ParameterDescription
    row_idROWID.
  • Example

    SELECT dbms_rowid.rowid_block_number(rowid)
    FROM table;

30.3.4. ROWID_ROW_NUMBER

Extracts and returns the row number in the block for the given ROWID.

Details about the ROWID_ROW_NUMBER function are as follows:

  • Prototype

    FUNCTION ROWID_ROW_NUMBER
    (
        row_id   IN   ROWID
    ) 
    RETURN NUMBER;
  • Parameter

    ParameterDescription
    row_idROWID.
  • Example

    SELECT dbms_rowid.rowid_row_number(rowid)
    FROM table;

30.3.5. ROWID_ABSOLUTE_FNO

Extracts and returns the absolute file number in the segment for the given ROWID.

Details about the ROWID_ABSOLUTE_FNO function are as follows:

  • Prototype

    FUNCTION ROWID_ABSOLUTE_FNO
    (
        row_id    IN   ROWID
    ) 
    RETURN NUMBER;
  • Parameter

    ParameterDescription
    row_idROWID.
  • Example

    SELECT dbms_rowid.rowid_absolute_fno(rowid)
    FROM table;

30.3.6. ROWID_TO_RELATIVE_FNO

Extracts the absolute file number for the given ROWID and converts it to a relative file number of the tablespace.

Details about the ROWID_TO_RELATIVE_FNO function are as follows:

  • Prototype

    FUNCTION ROWID_TO_RELATIVE_FNO
    (
        row_id    IN   ROWID
    ) RETURN NUMBER;
  • Parameter

    ParameterDescription
    row_idROWID.
  • Example

    SELECT dbms_rowid.rowid_to_relative_fno(rowid)
    FROM table;