Question

I needed some help in knowing whether we can have an option of sorting the rows of the table in Oracle based on the time of insertion.

Like do we use any sorting of function based indexes.

I would like to perform this operation of auto sorting without having to declare any new column for recording time.

Does the oracle server keep track of that information which i can use for sorting.

Thanks in advance

Was it helpful?

Solution

Oracle doesn't record the "time of insertion" for you, so you must add that column yourself, set it to the current time (e.g. SYSTIMESTAMP) on every insert, then ORDER BY that column when you query the table.

OTHER TIPS

The general answer is no.

However...

The ORA_ROWSCN pseudo column returns the conservative upper bound system change number (SCN) of the most recent change to the row. This pseudocolumn is useful for determining approximately when a row was last updated. It is not absolutely precise, because Oracle tracks SCNs by transaction committed for the block in which the row resides. You can obtain a more fine-grained approximation of the SCN by creating your tables with row-level dependency tracking.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top