12

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?

4
  • 7
    -1 for doing zero research - we call this laziness Commented May 24, 2012 at 5:36
  • hmm... why the downvote? This is an awesome question. +1. Yea I can google and this should show up. Commented Sep 6, 2012 at 4:05
  • 4
    +1 for putting this question into google search Commented Sep 6, 2012 at 4:06
  • 2
    I search google with 'how to change collection name mongo', and get this page :) Commented Mar 27, 2014 at 2:12

3 Answers 3

29
db.oldname.renameCollection("newname")
Sign up to request clarification or add additional context in comments.

Comments

3

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

> db.oldname.renameCollection("newname")

2 Comments

hehe, careless Google search. Thanks.
This post is a lot easier to sift through.
1
db.oldCollectionName.renameCollection("NewCollectionName")

Check Manual here.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.