Solved

rowid

Posted on 2011-02-16
8
1,274 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
Comment Utility
it's the "address" of a row

0
 
LVL 9

Assisted Solution

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

0
 

Author Comment

by:enrique_aeo
Comment Utility
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
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 94 total points
Comment Utility
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
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

Accepted Solution

by:
sdstuber earned 94 total points
Comment Utility
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]
Comment Utility
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
Comment Utility
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 34

Expert Comment

by:Mark Geerlings
Comment Utility
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.

Join & Write a Comment

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now