Database basic operations for MongoDB

Source: Internet
Author: User

Create a database

>use MyDB
Switched to DB MyDB

View all data Sheets

>show Collections
System.indexes

Create a data table

>db.createcollection ("Tb_user")
{"OK":1}

> Db.createcollection ("Test", {capped:true, size:10000}) {"OK": 1}

{"OK": 1}

--Description

Capped:true, which indicates that the structure of the collection cannot be modified;

Size: A certain amount of space is specified at the beginning of the table, and subsequent insertions continue sequentially append the data in this pre-allocated file, and if the space size is exceeded, back to the file header overwriting the original data and continuing the insertion. This structure guarantees the efficiency of insert and query, it does not allow the deletion of individual records, there is also a limit to update: cannot exceed the size of the original record. This kind of table is very efficient, it is suitable for some temporary preservation of the data, such as the site of the user's session information, such as some of the program's monitoring log, is a certain amount of time can be overwritten by the data.

Modify the data table name

>db.tb_user.renamecollection ("Tb_user1")
{"OK":1}

Database basic operations for MongoDB

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.