我现在有一个接口实现根据从文件中解析的数据在数据库中创建表(有几百张表),怎样通过Spring配置的事物,让其发生异常时,全量回滚呢????先谢谢各位了!

解决方案 »

  1.   

    写一个drop你这些表的procedure,然后在发生异常之后调用此procedure令其drop所有table伪代码:create or replace p_drop
    is
    begin
      drop table table1;
      drop table table2;
      ...
      ...
    end;从文件中解析的数据在数据库中创建表:
    begin
     create table1....
     create table2....
     ....
     ....
    exception when others then
      p_drop;
    end;
      

  2.   

    创建表是DDL操作,隐式自动提交,没有回滚操作
    1:但是你可以这样做,在你创建表之前先check point
    设置保存点,然后失败或者异常的话就 ROLLBACK 回保存点
    2:删除你创建的表。。
      

  3.   

    ddl语句没有回滚的
    不过你可以按照2楼的方法在创建表之前设置保存点。
    然后rollback to 保存点名
      

  4.   


    另外 你可以做batch处理 然后回滚