“uncap” a capped MongoDB collection

前端 未结 2 563
甜味超标
甜味超标 2021-01-18 06:12

is there a way to \"uncap\" a capped collection? Creating a new collection and copy the data isn\'t an option for me.

thanks

相关标签:
2条回答
  • 2021-01-18 06:32

    Unfortunately, the only option here is to copy collection, remove the old one and rename the new one:

    $> db.collection_name.copyTo('collection_name2')
    $> db.collection_name.isCapped()
    true
    $> db.collection_name.drop()
    $> db.collection_name2.renameCollection('collection_name')
    $> db.collection_name.isCapped()
    false
    
    0 讨论(0)
  • 2021-01-18 06:33

    No, You can convert a non-capped collection to a capped collection using the "convertToCapped" command but there's no way to go the other way.

    Your only option is to clone the collection to a non capped one and rename it which obviously involves downtime.

    0 讨论(0)
提交回复
热议问题