Data deletion of MongoDB basic operation

Source: Internet
Author: User
Tags mongodb
The delete operation uses remove, the data is deleted and the query is similar, accept a parameter, and the query is different, in order to prevent misoperation, the delete operation does not allow the parameter is not passed

Like what

Db.test_collection.remove ()
Will error
Error:remove needs a query: [email protected]/mongo/shell/collection.js:356:1[email protected]/mongo/shell/ Collection.js:383:18

When different from the update, the delete operation deletes all data that meets the criteria by default

> Db.test_collection.remove ({c:2"nremoved": 3})
From the feedback results can be seen, deleted 3 data, and then look for the C 2 data no longer exists

Delete a table

> db.test_collection.drop ()true
Again
Show tables
I can't see the data.

Data deletion of MongoDB basic operation

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.