Recent row entered

I have a very unusual question, how can one check which is the recent row added to a table?

Questions by akbarali   answers by akbarali

Editorial / Best Answer

biswaranjanbehera  

  • Member Since Jul-2008 | Aug 6th, 2008


We can select the recent row enrtered by using the query below.
suppose the table name is employee;
then.
select * from employee where rowid=(select max(rowid) from employee).
This works fine because rowid is assigned for each and every record and in accending order. So the recent record's rowid is the man (rowid). Please send feedback with any concern.

Showing Answers 1 - 0 of 0 Answers

We can select the recent row enrtered by using the query below.
suppose the table name is employee;
then.
select * from employee where rowid=(select max(rowid) from employee).
This works fine because rowid is assigned for each and every record and in accending order. So the recent record's rowid is the man (rowid). Please send feedback with any concern.

We can get the recent row entered by the help of this query below.

select * from employee where rowid=(select max(rowid) from employee);
because the rowid for the recent row entered in a table is always maximum (though it is stored in accending order).


thanks & regards
Biswaranjan

  Was this answer useful?  Yes

malapati

  • Oct 11th, 2008
 

 
select *from<table name> where rowid=(select max(rowid) from <table name>);


for eg:if we are having a table called "CUSTOMER" then;


select *from customer where rowid=(select max(rowid) from customer);   will show the recent entered record

  Was this answer useful?  Yes

dachi316

  • Aug 26th, 2009
 

SCOPE_IDENTITY() would be a better option to get the most recently added row as the primary key for a table may not necessarily be an auto-incrementing variable. Therefore max(rowid) would not be the optimal solution in that case.

  Was this answer useful?  Yes

bulat

  • May 31st, 2010
 

"Although a rowid uniquely identifies a row in a table, it might change its value if the underlying table is an index organized table or a partitioned table."

Also rowid stores information about physical location of the data, i.e.: file, block and row.

I don't think that there is any guaranty that RowId will be growing as records can get in several different files randomly.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions