Welcome Guest ( Log In | Register )


 
 
 
 
 
 

 
 
Oracle 

Performance Tuning Reference poster
 
Oracle training in Linux 

commands
 
Oracle training Weblogic Book
 
Easy Oracle Jumpstart
 
Oracle training & performance tuning books
 
Burleson Consulting Remote DB Administration
 
 
 
Reply to this topicStart new topic
> selecting from row id
rokyj055
post Apr 24 2012, 09:03 AM
Post #1


Advanced Member
***

Group: Members
Posts: 75
Joined: 23-January 12
Member No.: 46,637



Hi All,

I just want to know that "is it safe to select a columns using ROWID in a table?"

thanks in advance
Go to the top of the page
 
+Quote Post
burleson
post Apr 25 2012, 12:38 PM
Post #2


Advanced Member
***

Group: Members
Posts: 11,430
Joined: 26-January 04
Member No.: 13



>> "is it safe to select a columns using ROWID in a table?"


Safe? Define safe?


ROWID's can change, but you can use them in queries in some cases.


--------------------
Hope this helps. . .

Donald K. Burleson
Oracle Press author
Author of Oracle Tuning: The Definitive Reference
Go to the top of the page
 
+Quote Post
rokyj055
post Apr 28 2012, 05:35 AM
Post #3


Advanced Member
***

Group: Members
Posts: 75
Joined: 23-January 12
Member No.: 46,637



QUOTE (burleson @ Apr 25 2012, 12:38 PM) *
>> "is it safe to select a columns using ROWID in a table?"


Safe? Define safe?


ROWID's can change, but you can use them in queries in some cases.



Sir ,
Actually i wanted to select last 100 rows from a table.

desc t1
name varchar2(50)
address varchar2(50)

if this table table contained inter values then i cluld do it , but since it contains varchar datatype i did like following :

1.select rowid,name,address from t1;

<i got all row ids along with their name and address>
<then i found that 100th rowid starts from botton(last) of that table
suppose that 100th rowid from last is "asdfgha"
<and also i found last rowid of that table>
suppose that last rowid is "asdfghz"
<then i fired>
select rowid,name,address from t1 where rowid between 'asdfgha' and 'asdfghz' ;

----------------------------------------------------------------------------------------------------


But i think this not a good way to query like this ......

what if have crores of values in a table

..........









Go to the top of the page
 
+Quote Post
burleson
post Apr 28 2012, 05:52 PM
Post #4


Advanced Member
***

Group: Members
Posts: 11,430
Joined: 26-January 04
Member No.: 13



PLease read:

http://www.dba-oracle.com/t_select_last_100_rows.htm

>> select last 100 rows from a table.

Oracle does not store rows "first" or "last"!

The concept of a "Last Row " is only valid if we implement some type of ordering mechanism for the rowset (a key value).

ROWNUM is a psuedo-column, what you are doing will not always work!

A more permanent solution is to add a date-time column to the table. Then it makes sense to have a "last 100" rows, by time.


--------------------
Hope this helps. . .

Donald K. Burleson
Oracle Press author
Author of Oracle Tuning: The Definitive Reference
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 1st September 2014 - 06:15 AM