MongoDB Fixed Collection

Source: Internet
Author: User

Fixed Collection

The MongoDB fixed set (Capped collections) is a well-performing and fixed-size set, and for a fixed size we can imagine it to be like a ring queue , and when the set space is exhausted, the inserted element will overwrite The most initial element of the head!

Features: can be inserted and updated, but the update cannot exceed the size of the collection, otherwise the update fails, the deletion is not allowed, but you can call drop () to delete all the rows in the collection, but you need to explicitly rebuild the collection after the drop.

Back to Top

Example

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>

> Db.createcollection (, {capped:, size:, max:: >> db.del_col2.insert ({x:: > Db.del_col2.insert ({y:: > DB . Del_col2.insert ({z:: > Db.del_col2.insert ({m:: > Db.del_col2.: ObjectId (),:: ObjectId (),: > Db.del_col2 . Insert ({n:: > Db.del_col2.: ObjectId (),.: ObjectId (),: >::: >

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>

Convert to Fixed set

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>

> Db.col2.find () {"_id": ObjectId ("56C6CFD164799370C0EF35A2"), "X": 1} {"_id": ObjectId ("56C6CFD664799370C0EF35A3" ), "Y": 2} {"_id": ObjectId ("56c6cfdf64799370c0ef35a4"), "Z": 3}> db.col2.isCapped () false> Db.runcommand ({"Conv Erttocapped ":" Col2 ", size:1000}) {" OK ": 1}> db.col2.isCapped () True


MongoDB Fixed Collection

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.