Oracle 傻瓜式數據歸檔

推薦用方法二性能

 

方法一 【本庫備份,分區表須要另寫CREATE TABLE方法】
-----------------------------------------------
CREATE TABLE PH_PRESCRIPTION_T AS SELECT * FROM PH_PRESCRIPTION WHERE 1=0;
CREATE TABLE PH_PRESCRIPTION_ITEM_T AS SELECT * FROM PH_PRESCRIPTION_ITEM WHERE 1=0;
CREATE TABLE PH_AUDIT_PRESCRIPTION_T AS SELECT * FROM PH_AUDIT_PRESCRIPTION WHERE 1=0;
CREATE TABLE PH_AUDIT_PRESCRIPTION_ITEM_T AS SELECT * FROM PH_AUDIT_PRESCRIPTION_ITEM WHERE 1=0;

RENAME  PH_PRESCRIPTION TO PH_PRESCRIPTION_19;
RENAME  PH_PRESCRIPTION_T TO PH_PRESCRIPTION;

RENAME  PH_PRESCRIPTION_ITEM TO PH_PRESCRIPTION_ITEM_19;
RENAME  PH_PRESCRIPTION_ITEM_T TO PH_PRESCRIPTION_ITEM;

RENAME  PH_AUDIT_PRESCRIPTION TO PH_AUDIT_PRESCRIPTION_19;
RENAME  PH_AUDIT_PRESCRIPTION_T TO PH_AUDIT_PRESCRIPTION;

RENAME  PH_AUDIT_PRESCRIPTION_ITEM TO PH_AUDIT_PRESCRIPTION_ITEM_19;
RENAME  PH_AUDIT_PRESCRIPTION_ITEM_T TO PH_AUDIT_PRESCRIPTION_ITEM;


============================================================ 
方法二 先操做方法一,不然由於 數據量大,CREATE TABLE 時間長,形成數據丟失
-----------------------------------------------

CREATE TABLE PHARMACY_ARCHIVE.PH_PRESCRIPTION_19 AS SELECT * FROM PHARMACY.PH_PRESCRIPTION_19;
CREATE TABLE PHARMACY_ARCHIVE.PH_PRESCRIPTION_ITEM_19 AS SELECT * FROM PHARMACY.PH_PRESCRIPTION_ITEM_19;
CREATE TABLE PHARMACY_ARCHIVE.PH_AUDIT_PRESCRIPTION_19 AS SELECT * FROM PHARMACY.PH_AUDIT_PRESCRIPTION_19;
CREATE TABLE PHARMACY_ARCHIVE.PH_AUDIT_PRESCRIPTION_ITEM_19 AS SELECT * FROM PHARMACY.PH_AUDIT_PRESCRIPTION_ITEM_19;
DROP TABLE PHARMACY.PH_PRESCRIPTION_19;
DROP TABLE PHARMACY.PH_PRESCRIPTION_ITEM_19;
DROP TABLE PHARMACY.PH_AUDIT_PRESCRIPTION_19;
DROP TABLE PHARMACY.PH_AUDIT_PRESCRIPTION_ITEM_19;

============================================================ 
方法三,原理等同於方法二,性能高於方法二。再用 導出、導入 方法
-----------------------------------------------
expdp pharmacy_archive/pharmacy_archive directory=dump_dir dumpfile=LH_BAK_20190228.dmp tables=PH_PRESCRIPTION_19,PH_PRESCRIPTION_ITEM_19,PH_AUDIT_PRESCRIPTION_19,PH_AUDIT_PRESCRIPTION_ITEM_19 logfile=EXP_LH_BAK_20190228.log compression=all
impdp 導入 
DROP TABLE PHARMACY.PH_PRESCRIPTION_19;
DROP TABLE PHARMACY.PH_PRESCRIPTION_ITEM_19;
DROP TABLE PHARMACY.PH_AUDIT_PRESCRIPTION_19;
DROP TABLE PHARMACY.PH_AUDIT_PRESCRIPTION_ITEM_19;
相關文章
相關標籤/搜索