发布于 2015-09-14 14:59:41 | 203 次阅读 | 评论: 0 | 来源: 网络整理

convertToCapped

The convertToCapped command converts an existing, non-capped collection to a capped collection within the same database.

The command has the following syntax:

{convertToCapped: <collection>, size: <capped size> }

convertToCapped takes an existing collection (<collection>) and transforms it into a capped collection with a maximum size in bytes, specified to the size argument (<capped size>).

During the conversion process, the convertToCapped command exhibit the following behavior:

  • MongoDB transverses the documents in the original collection in natural order and loads the documents into a new capped collection.
  • If the capped size specified for the capped collection is smaller than the size of the original uncapped collection, then MongoDB will overwrite documents in the capped collection based on insertion order, or first in, first out order.
  • Internally, to convert the collection, MongoDB uses the following procedure
    • cloneCollectionAsCapped command creates the capped collection and imports the data.
    • MongoDB drops the original collection.
    • renameCollection renames the new capped collection to the name of the original collection.

注解

MongoDB does not support the convertToCapped command in a sharded cluster.

警告

The convertToCapped will not recreate indexes from the original collection on the new collection. If you need indexes on this collection you will need to create these indexes after the conversion is complete.

也可以参考

create

警告

This command obtains a global write lock and will block other operations until it has completed.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务