Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

rowid

Posted on 2011-02-16
8
Medium Priority
?
1,296 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 376 total points
ID: 34910467
it's the "address" of a row

0
 
LVL 9

Assisted Solution

by:AriMc
AriMc earned 124 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 376 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 376 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

715 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