ITPub博客

首页 > 数据库 > Oracle > 备份表,并清空原表

备份表,并清空原表

原创 Oracle 作者:we6100 时间:2015-11-06 17:19:14 0 删除 编辑
declare
  v_cnt number(1);
begin
  select count(1) into v_cnt from user_tables where lower(table_name)='t_batch_job_sub_bak';
  if v_cnt > 0 then
 execute immediate 'drop table t_batch_job_sub_bak'; 
  end if;
  execute immediate 'create table t_batch_job_sub_bak as select * from t_batch_job_sub';

execute immediate 'alter table t_batch_job_sub disable constraint FK_BATCH_JOB_SUB__PIECE_ID';

execute immediate 'truncate table t_batch_job_sub';

execute immediate 'alter table t_batch_job_sub enable constraint FK_BATCH_JOB_SUB__PIECE_ID';

end;
/

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27500440/viewspace-1824875/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-02-23

  • 博文量
    72
  • 访问量
    294578