global class DeleteSObjectBatch implements Database.Batchable, Database.Stateful{ ////删除数据bacth 精琢技术 wql 2021/09/10 start public String query; global DeleteSObjectBatch(String sObjectName){ this.query = 'select Id from '+sObjectName; } global DeleteSObjectBatch(String sObjectName,String whereName){ this.query = 'select Id from '+sObjectName+' where '+whereName; } global Database.QueryLocator start(Database.BatchableContext bc) { system.debug('sql:'+query); return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, list scope) { if(scope.size()>0){ delete scope; } } global void finish(Database.BatchableContext BC) { } //删除数据bacth 精琢技术 wql 2021/09/10 end }