MongoDB Database Common Operations

Source: Internet
Author: User
Tags logical operators

First, the database operation

1. View the current database name

2. View all database names

3. Toggles the database if the database does not exist and is not created until the database is created when the data is inserted or the collection is created


4. Delete the currently pointing database and do nothing if the database does not exist



Second, set operation

1. Create a Collection

2. View a collection of current databases


3. Delete Collection

Third, data additions and deletions to change


1. Inserting data

Note: If you do not specify _ID,MONGODB when inserting data, you will automatically assign a

2. Update data

3. Save Data

4. Delete
iv. data Query

1. Search All

2. Querying a single piece of data

3. Format Query

  comparison Operators

4. query for age greater than or equal to 18
  logical operators $or and and

5. Scope Query

6. Gets the specified data entry limit

7. Skip the specified entry skip

8. Projection (just show the fields you want to see)

9. Sort

10. Statistics Count

11. Go to heavy distinct

Five, aggregate function Aggregate

Common expressions

For example:total number of students, average age
Pivot data (that is, the data is displayed in categories)

For example: statistics on student gender and student name

Vi. Index

1. Create an index

2. The ability to create unique indexes to implement unique constraints
3. View all indexes on a document

4. Delete Index

Vii. Backup

1. Backing up data

2. Recovering Data





MongoDB Database Common Operations

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.