Solved

rowid

Posted on 2011-02-16
8
1,279 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
 
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
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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle function works in 11g but not in 12c 21 72
Oracle RMAN Database Restore 5 51
Oracle Syntax 8 56
Query to identify changes between rows of two tables 8 37
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
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.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
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.

920 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

16 Experts available now in Live!

Get 1:1 Help Now