Normally, we can find row_number based on the order of columns using ROW_NUMBER() function.
select row_number() over(order by col1) from tablename ;
Is there any way in Teradata to get the Row number based on the order/time of insertion rather than the order of columns contained.
Thanks in advance.
you could save timestamp of insertion into a separate column (during inserts), and use it for that purpose. It would take more perm space to store the table though.
Not that I'm aware of, sorry. Rowids in Teradata do not impose sequential order the way you describe it.
I dont think you will be able to select the rows the same way you had inserted. Though one way would be, if you are inserting into a table in a particular order try to insert the row number for that particular order as one column and while selecting use order by on that extra column.
While inserting if you dont specify any order(and put that row_number as one column), i dont think its possible at all to select in any particular order.
Also inserting timestamp wont work, because for most of the records you will have same timestamp.