Rename column name in MongoDB (change field name)

Source: Internet
Author: User

Rename column name in MongoDB (change field name)Category: Database 2012-06-11 11:071648 people read comments (0) favorite reports Mongodbshell2010c

Transferred from: HTTP://HI.BAIDU.COM/YOUHONG2010/ITEM/6BB2F020115394846E2CC3B6

See also: Http://www.mongodb.org/display/DOCS/Updating#Updating-%24rename

Cases:

Shell Code

    1. Db.test.find ()

Find the following data:

Shell Code

    1. {"_id": ObjectId ("4e787a369748ed04b7c19b0f"), "abc": "123"}

Now, you need to change the field "ABC" to "Def" and execute the following command:

Shell Code

    1. Db.test.update ({}, {$rename: {"abc": "Def"}}, False, True)

Can.

PS: If the amount of data is large, the column name of all data will not be renamed immediately, the execution time is required.

Rename column name in MongoDB (change field name)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.