Oracle 12C--In-database archiving

Source: Internet
Author: User

In the same table, the data is archived by placing the row in the inactive state. Database, you can compress optimizations for those inactive row. While archiving is implemented, applications can be restricted from accessing only those data in the active state. By default, those inactive row are not available to the app.

turn on the in-database archiving function of the table and use the keyword "row archival" when creating the table. Tables created with the keyword "row archival" add a hidden column: Ora_archive_state.

Sql> CREATE TABLE Emp_indbarch (emp_id number (6) notNULL, Name VARCHAR2 ( -), Hire_date date notNULL, job_id varchar2 (5) notNULL, Salary number (6) ) row archival; SQL> INSERT into Emp_indbarch (emp_id, Name,hire_date, job_id, salary) VALUES (1,'Scott','21-may-2009','Dev',50000); SQL> INSERT into Emp_indbarch (emp_id, Name,hire_date, job_id, salary) VALUES (2,'Jane','11-jun-2009','pm',30000); SQL>commit; SQL>SelectOra_archive_state,emp_id,name fromemp_indbarch;ora_archive_state emp_id NAME------------------------------ ---------- --------------------0                                       1Scott0                                       2Janesql>

The value of the hidden column ora_archive_state is 0 by default, indicating that row is active. A value of non 0 o'clock indicates that the row is inactive.

Manually modify active to inactive

set ora_archive_state=1where emp_id=1; SQL> commit;

By default , the inactive row is not visible for sessions and applications: (equivalent to alter session set row archival visibility=active)

Select  from emp_indbarch;ora_archive_state                  emp_id NAME------------------------------------------------------------0                                       2  Janesql


Setting inactive data is visible to the app:

set row Archival visibility = all ; Session altered. SQLSelect from emp_indbarch;ora_archive_state                  emp_id NAME-------------------- ----------------------------------------1                                       1  Scott0                                       2 Janesql


Cancel the In-database archiving function of the table:

sql> ALTER TABLE Emp_indbarch no row archival; Table altered. SQLSelect from emp_indbarch; Select  from Emp_indbarch        *1: ORA-00904"ora_archive_state": Invalid Identifiersql

Oracle 12C--In-database archiving

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.