重命名集合

mongoshell里就可以实现

db.orders.renameCollection( "orders2014" )

通过cmd:renameCollection重命名数据库

没有直接的接口,直接copydb数据很多时比较费时间,不过可以通过

{ renameCollection: "<source_namespace>", to: "<target_namespace>", dropTarget: <true|false> }

dropTarget boolean 是否在集合同名时删除原集合,默认为true
该操作会阻塞所有数据库操作
例子

db.runCommand( { renameCollection: "test.orders", to: "test.orders2014" }

如果要重命名数据库,使用js做一个循环的函数便搞定

相关文章:

  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-06-27
  • 2021-07-21
  • 2022-03-10
猜你喜欢
  • 2022-01-24
  • 2022-12-23
  • 2021-08-13
  • 2021-11-19
  • 2021-11-09
  • 2021-05-31
相关资源
相似解决方案