cloneCollectionAsCapped
On this page本页内容
Definition定义
cloneCollectionAsCapped
-
ThecloneCollectionAsCapped
command creates a new capped collection from an existing, non-capped collection within the same database. The operation does not affect the original non-capped collection.cloneCollectionAsCapped
命令从同一数据库中现有的未封顶集合创建一个新的封顶集合。该操作不会影响原始的非封顶集合。
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.runCommand(
{
cloneCollectionAsCapped: <existing collection>,
toCollection: <capped collection>,
size: <capped size>,
writeConcern: <document>,
comment: <any>
}
)
Command Fields命令字段
The command takes the following fields:该命令包含以下字段:
cloneCollectionAsCapped | |
toCollection | |
size | |
writeConcern | drop command. Omit to use the default write concern.drop 命令的写入关注的文档。忽略使用默认的写入关注。 |
comment |
|
The command copies an 该命令复制现有集合,并创建一个新的封顶集合,该集合的最大大小由existing collection
and creates a new capped collection
with a maximum size specified by the capped size
in bytes.capped size
(以字节为单位)指定。
To replace the original non-capped collection with a capped collection, use the 若要封顶集合替换原始的非封顶集合,请使用convertToCapped
command.convertToCapped
命令。
Behavior行为
If the 如果capped size
is less than the size of the source collection, then not all documents in the source collection will exist in the destination capped collection.capped size
小于源集合的大小,则并非源集合中的所有文档都将存在于目标封顶集合中。
This holds a database exclusive lock for the duration of the operation. Other operations which lock the same database will be blocked until the operation completes. See What locks are taken by some common client operations? for operations that lock the database.这将在操作期间保留数据库独占锁。锁定同一数据库的其他操作将被阻止,直到操作完成。请参阅一些常见的客户端操作使用哪些锁?用于锁定数据库的操作。