oracle 12c 資料歸檔 即Using In-Database Archiving feature
在oracle 12c 透過Using In-Database Archiving feature 特性,來啟到分離線上資料和歷史資料的作用, 即資料歸檔,應用可以有選擇性的訪問線上資料或者歷史資料,要啟用這個特性,在建表的時候啟用ROW ARCHIVAL, 並操作ORA_ARCHIVE_STATE 這個隱藏欄位,此外使用者還可以指定會話級別的 ROW ARCHIVAL VISIBILITY為ACTIVE 或者ALL active就是看到線上資料,ALL的話就是全部資料。 /* Set visibility to ACTIVE to display only active rows of a table.*/ ALTER SESSION SET ROW ARCHIVAL VISIBILITY = ACTIVE; CREATE TABLE employees_indbarch (employee_id NUMBER(6) NOT NULL, first_name VARCHAR2(20), last_name VARCHAR2(25) NOT NULL, email VARCHAR2(25) NOT NULL, phone_number VARCHAR2(20), hire_date DATE NOT NULL, job_id VARCHAR2(10) NOT NULL, salary NUMBER(8,2), commission_pct NUMBER(2,2), manager_id NUMBER(6), department_id NUMBER(4)) ROW ARCHIVAL; INSERT INTO employees_indbarch(employee_id, first_name, last_name, email, hire_date, job_id, salary, manager_id, department_id) VALUES (251, 'Scott', 'Tiger', 'scott.tiger@example.com', '21-MAY-2009', 'IT_PROG', 50000, 103, 60); INSERT INTO employees_indbarch(employee_id, first_name, last_name, email, hire_date, job_id, salary, manager_id, department_id) VALUES (252, 'Jane', 'Lion', 'jane.lion@example.com', '11-JUN-2009', 'IT_PROG', 50000, 103, 60); /* Show all the columns in the table, including hidden columns */ SELECT SUBSTR(COLUMN_NAME,1,22) NAME, SUBSTR(DATA_TYPE,1,20) DATA_TYPE, COLUMN_ID AS COL_ID, SEGMENT_COLUMN_ID AS SEG_COL_ID, INTERNAL_COLUMN_ID AS INT_COL_ID, HIDDEN_COLUMN, CHAR_LENGTH FROM USER_TAB_COLS WHERE TABLE_NAME='EMPLOYEES_INDBARCH'; NAME DATA_TYPE COL_ID SEG_COL_ID INT_COL_ID HID CHAR_LENGTH ---------------------- -------------------- ---------- ---------- ---------- --- ----------- ORA_ARCHIVE_STATE VARCHAR2 1 1 YES 4000 EMPLOYEE_ID NUMBER 1 2 2 NO 0 FIRST_NAME VARCHAR2 2 3 3 NO 20 LAST_NAME VARCHAR2 3 4 4 NO 25 EMAIL VARCHAR2 4 5 5 NO 25 PHONE_NUMBER VARCHAR2 5 6 6 NO 20 HIRE_DATE DATE 6 7 7 NO 0 JOB_ID VARCHAR2 7 8 8 NO 10 SALARY NUMBER 8 9 9 NO 0 COMMISSION_PCT NUMBER 9 10 10 NO 0 MANAGER_ID NUMBER 10 11 11 NO 0 DEPARTMENT_ID NUMBER 11 12 12 NO 0 /* Decrease the ORA_ARCHIVE_STATE column size to improve formatting in queries */ COLUMN ORA_ARCHIVE_STATE FORMAT a18; /* The default value for ORA_ARCHIVE_STATE is '0', which means active */ SELECT employee_id, ORA_ARCHIVE_STATE FROM employees_indbarch; EMPLOYEE_ID ORA_ARCHIVE_STATE ----------- ------------------ 251 0 252 0 /* Insert a value into ORA_ARCHIVE_STATE to set inactive */ UPDATE employees_indbarch SET ORA_ARCHIVE_STATE = '20' WHERE employee_id = 252; /* Only active records are in the following query */ SELECT employee_id, ORA_ARCHIVE_STATE FROM employees_indbarch; EMPLOYEE_ID ORA_ARCHIVE_STATE ----------- ------------------ 251 0 /* Set visibility to ALL to display all records */ ALTER SESSION SET ROW ARCHIVAL VISIBILITY = ALL; SELECT employee_id, ORA_ARCHIVE_STATE FROM employees_indbarch; EMPLOYEE_ID ORA_ARCHIVE_STATE ----------- ------------------ 251 0 252 20
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-2058720/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 12c 新特性之 資料庫內歸檔(In-Database Archiving)Oracle資料庫Database
- Oracle Database 12c新特性 In-Database Archiving資料庫內歸檔OracleDatabase資料庫
- [20130817]Oracle 12c new feature In-Database Archiving.txtOracleDatabase
- G009-ORACLE-ASK Using In-Database ArchivingOracleDatabase
- ORACLE 12C 開啟資料庫歸檔模式Oracle資料庫模式
- 12c in-database archiveDatabaseHive
- ORACLE資料庫歸檔改為非歸檔Oracle資料庫
- Oracle 12c 關閉歸檔模式Oracle模式
- Oracle Database 12C New FeatureOracleDatabase
- Oracle閃回資料歸檔Oracle
- Oracle 12c Recover Table New FeatureOracle
- Oracle資料庫開啟歸檔Oracle資料庫
- 開啟oracle資料庫歸檔Oracle資料庫
- 檢視oracle資料庫是否歸檔和修改歸檔模式Oracle資料庫模式
- oracle 12c new feature 列不可見Oracle
- oracle資料庫更改歸檔路徑Oracle資料庫
- oracle 修改資料庫為歸檔模式Oracle資料庫模式
- Oracle資料庫切換歸檔模式Oracle資料庫模式
- 檢視oracle資料庫是否歸檔和修改歸檔模式(轉)Oracle資料庫模式
- Oracle 12c: Recover tables using RMANOracle
- 12c new feature
- oracle 交換分割槽歷史資料歸檔Oracle
- Oracle 11g 閃回資料歸檔Oracle
- oracle RMAN 非歸檔資料庫恢復Oracle資料庫
- oracle 歸檔/非歸檔Oracle
- oracle資料庫歸檔日誌量陡增分析Oracle資料庫
- Oracle資料庫歸檔模式的切換ELOracle資料庫模式
- [zt] Oracle 11g 閃回資料歸檔Oracle
- 檢視oracle資料庫是否為歸檔模式Oracle資料庫模式
- oracle資料庫rman歸檔設定和管理Oracle資料庫
- SQL資料庫怎麼進行資料歸檔和歸檔管理?SQL資料庫
- oracle歸檔Oracle
- Oracle 12C 新特性:關於歸檔日誌的備份Oracle
- oracle 12c new feature crsctl 停止資源時提供預覽確認功能Oracle
- 關於oracle閃回資料歸檔的總結Oracle
- Oracle 12C 新特性之資料檔案線上遷移Oracle
- oracle歸檔模式下imp匯入資料,產生的歸檔日誌大小記錄Oracle模式
- Oracle 12C Transport a Database to a Different Platform Using Backup SetsOracleDatabasePlatform