Thursday, August 27, 2015

How To Archive Table Rows In Oracle 12c

source : http://dbaclass.com/index.php/article/how-to-archive-rows-in-oracle-12c/

In oracle 12c a new feature called In-Database Archiving has been introduced. With this we can archive specific rows of a table as per our requirement. This is very helpful,when table contains lot of historical data and for full scan it is taking a lot of time.Using this we can archive the historical data.
We will see an example:
You can check the explain plan( Scanning all 8 rows)
Enable archiving of that table.
This will create one invisible column ORA_ARCHIVE_STATE:(0/1)
ORA_ARCHIVE_STATE:0 – Means that row is not archived
ORA_ARCHIVE_STATE:1 – Means that row is archived
Lets archive the rows whose EMP is 1 or 2 .
Now we can see the table has 6 rows and rest were archived.
If you check the explain ( It will scan only 6 rows, excluding the archival rows)
If you want to see the rows including archived rows at session level , then use
For disabling archiving:
This will drop that invisible colum

No comments:

Post a Comment