Solved

rowid

Posted on 2011-02-16
8
1,282 Views
Last Modified: 2012-08-13
please, can you explain it means rowid

0
Comment
Question by:enrique_aeo
8 Comments
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 94 total points
ID: 34910467
it's the "address" of a row

0
 
LVL 9

Assisted Solution

by:AriMc
AriMc earned 31 total points
ID: 34910471
Rowid is an internal identifier that is maintained by Oracle and unique for every row in the database.

0
 

Author Comment

by:enrique_aeo
ID: 34910503
select   ...
from tmp_Solicitud ts
where (ts.CodUnico, ts.rowid) in
      (
      select t.CodUnico, min(t.rowid)
      from tmp_Solicitud t
      group by t.CodUnico
      );

and used in the where?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 94 total points
ID: 34910511
using rowid Oracle can identify the file, block and offset within a block to find the row

for more information,  mrjoltcola wrote up a description of some of the info contained within a rowid

http://www.experts-exchange.com/Database/Oracle/A_931-Decoding-the-Oracle-ROWID-and-some-Base64-for-fun.html
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 94 total points
ID: 34910548
in that usage you have multiple rows with the same CodUnico  value

min(rowid) picks one of them,  effectively at "random"
it's the smallest rowid, but that implies nothing about the values of the column (other than those specified by the query) and certainly not anything about the order the rows were created and/or updated.

So, this query searches through your table and picks one row for each CodUnico

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34910678
note that you should never "remember" a rowid for later use... between the time you fetched it and want to use it again, the row might have been moved, and hence changed it's row id.
this is occuring when rows are updated, deleted and inserted into the table (it might be because of other rows modified that "your" row gets a new rowid, hence !
0
 
LVL 11

Expert Comment

by:Akenathon
ID: 34910686
The ROWID is an encoded address to where a row physically resides, namely to the Oracle datafile number, block number within the datafile and row number within the block.

Your select is just trying to get only one row for each t.CodUnico. If you don't really use the rowid, it would give the same results if you use MAX(t.rowid). It's just a way to choose one row among many "similar" ones. You can just as well replace it in the inner subquery with (select DISTINCT CodUnico from tmp_Solicitud).

Now, if below that select it does something with the fetched rowid, don't mess with the code too much before contacting the original coder.
0
 
LVL 35

Expert Comment

by:Mark Geerlings
ID: 34910696
Others have explained already what "rowid" is in Oracle.  You had asked for a way to get just the unique (or "distinct") CodUnico values from a table, so the query I gave you did that by using "group by CodUnico" along with a group operator (min) on another column.  Since "rowid" is a logical address for a single record in Oracle, I used "min(rowid)" in that query to just find the "first" row that matched the CodUnico value.  But, as stsuber indicated, this does not guarantee that the other columns of this row have the values you want.  
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to recover a database from a user managed backup

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question