发布于 2015-09-14 15:03:32 | 108 次阅读 | 评论: 0 | 来源: 网络整理

db.collection.renameCollection()

db.collection.renameCollection() provides a helper for the renameCollection database command in the mongo shell to rename existing collections.

参数:
  • target (string) – Specifies the new name of the collection. Enclose the string in quotes.
  • dropTarget (boolean) – Optional. If true, mongod will drop the target of renameCollection prior to renaming the collection.

Call the db.collection.renameCollection() method on a collection object, to rename a collection. Specify the new name of the collection as an argument. For example:

db.rrecord.renameCollection("record")

This operation will rename the rrecord collection to record. If the target name (i.e. record) is the name of an existing collection, then the operation will fail.

Consider the following limitations:

The db.collection.renameCollection() method operates within a collection by changing the metadata associated with a given collection.

Refer to the documentation renameCollection for additional warnings and messages.

警告

The db.collection.renameCollection() method and renameCollection command will invalidate open cursors which interrupts queries that are currently returning data.

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

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