oracle 定期迁移分区表数据(不落地)

Posted 钱若离花落

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 定期迁移分区表数据(不落地)相关的知识,希望对你有一定的参考价值。

[[email protected] ~]$ cat /home/oracle/JY_SJ.sh
#!/bin/bash
source /home/oracle/.bash_profile
SDATE=$(date  +%Y%m)
TDATE=$(date -d "-1 month" +%Y%m)
SPNAME="P"${SDATE}
TPNAME="P"${TDATE}
#@/home/oracle/truncate.sql

sqlplus / as sysdba > /home/oracle/SJ_PAR_`date +%y%m%d%H`.log<<EOF
alter session set container=SJDB;
set feedback off heading off term off
set pages 0 trim on trims on lines 32767 long 999999
set echo off
spool SJ_PAR.sql

select count(*) from SJ.T_TEST_INF_SJ partition ($SPNAME);  
select count(*) from SJ.T_TEST_INF_JY partition ($TPNAME);

alter table SJ.T_TEST_INF_SJ truncate partition $TPNAME;
alter table SJ.T_TEST_INF_JY truncate partition $SPNAME;

select count(*) from SJ.T_TEST_INF_SJ partition ($SPNAME);
select count(*) from SJ.T_TEST_INF_JY partition ($TPNAME);

spool off
exit
EOF
logname=`date +%y%m%d%H`
impdp \‘sys/[email protected] as sysdba\‘ content=data_only logfile=$logname.log directory=SJ tables=SJ.T_TEST_INF_SJ:$TPNAME,SJ.T_TEST_INF_JY:$SPNAME remap_tablespace=SS_data:SJ_data,SS_idx:SJ_idx remap_schema=SS:SJ network_link=SJ_JY

 




















以上是关于oracle 定期迁移分区表数据(不落地)的主要内容,如果未能解决你的问题,请参考以下文章

Oracle用分区表分区交换做历史数据迁移

针对分区表一个月3个分区定期清理脚本

Oracle 11g 新特性:自动创建分区(Interval Partition)

MySQL8数据迁移大表捷径【表空间迁移】

ORACLE表索引和分区

Oracle 11g新特性 Interval Partition