批量删除test开头的表

 

 

 

 

db.getCollectionNames().forEach(function(collectionName) {
  if (collectionName.startsWith('test')) {
    db.getCollection(collectionName).deleteMany({});
    print(`Collection ${collectionName} has been cleared`);
  }
});

 

posted @ 2024-02-04 12:17  AngDH  阅读(4)  评论(0编辑  收藏  举报