Solved

rowid

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

0
Comment
Question by:enrique_aeo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 74

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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 74

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 74

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 143

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to take different types of Oracle backups using RMAN.

734 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