MongoDB: How To Delete All Records Of A Collection in MongoDB Shell?

后端 未结 5 1148
生来不讨喜
生来不讨喜 2021-01-30 15:23

I\'ve tried

db.users.remove(*)

Although it returns an error so how do I go about clearing all records?

5条回答
  •  长发绾君心
    2021-01-30 16:18

    Delete all documents from a collection in cmd:

    cd C:\Program Files\MongoDB\Server\4.2\bin
    mongo
    use yourdb
    db.yourcollection.remove( { } )
    

提交回复
热议问题