cd util vi install_server.sh # 注释下面的内容 #bail if this system is managed by systemd #_pid_1_exe="$(readlink -f /proc/1/exe)" #if [ "${_pid_1_exe##*/}" = systemd ] #then # echo "This systems seems to use systemd." # echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!" # exit 1 #fi #unset _pid_1_exe ./install_server.sh # 输入端口号等,按照提示输入对应内容即可
create or replace procedure delete_partition(tb_name varchar2) is -- 分区位置编码 max_position number; -- 循环临时变量 cnt number; -- 分区名称 ptn_name varchar2(64); -- 删除分区的sql语句 sql_str varchar2(255); begin -- partition_position位置从1开始自增 select max(partition_position) into max_position from user_tab_partitions where table_name = tb_name; if max_position > 2 then -- 每次清除位置从2到max_position-1上的表分区内容,1位置为初始创建的表分区,不能删除,最大一个位置的为最后一个,又可能正在写数据,也不删除 for cnt in 2..(max_position-1) loop select partition_name into ptn_name from user_tab_partitions where table_name = tb_name and partition_position = cnt; sql_str := 'alter table '||tb_name||' drop partition '||ptn_name||' update global indexes'; execute immediate sql_str; end loop; commit; end if; end delete_partition;
3、创建定时job
创建job,定时调用清除分区的存储过程。
1 2 3 4 5
DECLARE job NUMBER; BEGIN dbms_job.submit(job,'DELETE_PARTITION(''CUST_TB'');',sysdate,'sysdate+10/1440'); END;
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.