In this article, we will see the syntax to rename collection and examples to rename collections in MongoDB.
What happens when renaming collection in MongoDB?
db.collection.renameCollection() obtains an exclusive lock on the specified collections for the duration of the operation. All subsequent operations on the collections must wait until db.collection.renameCollection() releases the lock.
Syntax to rename collection in MongoDB:
db.collection.renameCollection(target, dropTarget)