删除大量数据高效方法:

第一种:

在D 盘建一个empty.del文件。然后通过import命令import from empty.del of del replace into [table_name]来清空表中的数据并重组表空间。

 

效率很快

第二种:

在建表时加选项not logged initially ,当清空表时通过alter table [name] activate not logged initially with empty table 。

 

注意操作效率高就关闭日志记录,通过“alter table tableName activate not logged INITIALLY”关闭日志打印,只在执行一次sql后失效

尽量避免在上线之初直接使用“ INSERT INTO … SELECT .. FROM .. ”语句,导入一个很大的事务的方式进行导数,这样会使事务非常大

 

echo "\n开始清理 table 表TBL_SWINDLE"
  db2 connect to elloc user easylink using elinkgit
  db2 +c "select count(*) from TBL_SWINDLE where flag=1";
  db2 "export to TBL_SWINDLE.del of del select * from TBL_SWINDLE";
  db2 +c "alter table TBL_SWINDLE activate not logged INITIALLY"; //关闭日志打印 只在执行一次sql后失效
  db2 +c "delete from TBL_SWINDLE where flag=1";
  db2 -v commit;
  echo "table 表清理完毕!\n"

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2022-01-17
  • 2022-12-23
  • 2021-06-22
  • 2021-11-30
  • 2022-12-23
  • 2021-10-08
  • 2021-10-25
相关资源
相似解决方案