xiaohan2012
xiaohan2012

Reputation: 10342

Change collection name in mongodb

Changing the name of a collection in mongodb can be achieved by copy the documents in the collection to a new one and delete the original.

But is there a simpler way to change the name of a collection in mongodb?

Upvotes: 12

Views: 8448

Answers (3)

Sadikhasan
Sadikhasan

Reputation: 18601

db.oldCollectionName.renameCollection("NewCollectionName")

Check Manual here.

Upvotes: 1

jdi
jdi

Reputation: 92657

Really? No google search?
http://www.mongodb.org/display/DOCS/renameCollection+Command

> db.oldname.renameCollection("newname")

Upvotes: 3

James Gan
James Gan

Reputation: 7146

db.oldname.renameCollection("newname")

Upvotes: 29

Related Questions