-- oracle分區表備份恢復 --1,測試數據: drop tablespace tbs2 including contents and datafiles; create tablespace tbs2 datafile '/ora01/app/oracle/oradata/prodc/tbs1.dbf' size 10M; create user loge1 identified by china default tablespace tbs2; grant connect,resource,dba to loge; drop tablespace tbs2 including contents and datafiles; create tablespace tbs2 datafile '/ora01/app/oracle/oradata/prodc/tbs1.dbf' size 10M; create user loge1 identified by china default tablespace tbs2; grant connect,resource,dba to loge1; -- 使用帳號loge登錄執行 create table p_t1 (id int,datatime date) partition by range(datatime) (partition p1 values less than (to_date('2016-01-01','yyyy-mm-dd')), partition p2 values less than (to_date('2016-02-01','yyyy-mm-dd')), partition p3 values less than (to_date('2016-03-01','yyyy-mm-dd'))); insert into p_t1 values(1,to_date('2016-01-01','yyyy-mm-dd')); insert into p_t1 values(2,to_date('2016-02-01','yyyy-mm-dd')); insert into p_t1 values(3,to_date('2016-03-01','yyyy-mm-dd')); commit; -- 查看 select table_name,partition_name,high_value from user_tab_partitions where table_name='P_T1' select * from p_t1; select * from p_t1 partition(p1); select * from p_t1 partition(p2); -- 建立間隔分區 select table_name,partition_name,high_value from user_tab_partitions where table_name='P_T2' create table p_t2 (id int,datatime date) partition by range(datatime) interval(numtoyminterval(1,'MONTH')) (partition part0601 values less than (to_date('2016-02-01','yyyy-mm-dd'))); --不容許間隔分區添加分區 alter table p_t2 add partition part0602 values less than (to_date('2016-03-01','yyyy-mm-dd')); ORA-14760: ADD PARTITION is not permitted on Interval partitioned objects -- 若是非間隔分區添加分區,好比大於最後一個分區,不然報錯 alter table p_t1 add partition part0602 values less than (to_date('2016-03-01','yyyy-mm-dd')); ORA-14074: partition bound must collate higher than that of the last partition -- 拆分分區 alter table p_t1 split partition p3 at(to_date('2016-02-15','yyyy-mm-dd')) into (partition p31,partition p32); -- 合併分區 alter table p_t1 merge partitions p31,p32 into partition p3; -- 2,執行導出導入 -- exp導出 exp loge/china tables=p_t1 file=/home/oracle/bak/exp_table.dmp exp loge/china tables=p_t1:p1 file=/home/oracle/bak/exp_table_p1.dmp -- imp導入 imp loge1/china tables=p_t1 file=/home/oracle/bak/exp_table.dmp imp loge/china tables=p_t1:p2 file=/home/oracle/bak/exp_table_p1.dmp -- expdp導出 expdp loge/china directory=dump_dir dumpfile=dump_table.dmp tables=p_t1 -- expdp導入 impdp loge1/china directory=dump_dir dumpfile=dump_table.dmp tables=loge.p_t1 content=metadata_only remap_schema=loge:loge1 remap_tablespace=tbs1:tbs2 impdp loge1/china directory=dump_dir dumpfile=dump_table.dmp tables=loge.p_t1 content=data_only remap_schema=loge:loge1 remap_tablespace=tbs1:tbs2 表存在的幾種處理:TABLE_EXISTS_ACTION APPEND, REPLACE, [SKIP] 和 TRUNCATE 注意: 若是是本身建立的分區好比按照job建立的分區,注意建表的ddl,不然導入失敗