MongoDB drop collection examples (using the mongo command line)

I accidentally created some MongoDB collections within my database named "stickynotes" that I didn't want. All I wanted was a collection named notes, but I was fooling around and accidentally created some other collections. Here's how I deleted those collections using the mongo command line. (My commands are shown in bold.)

> use stickynotes
switched to db stickynotes

> show collections
notes
stickynotes
stickynotes.notes
system.indexes

> db.stickynotes.drop()
true

> show collections
notes
stickynotes.notes
system.indexes

> db.stickynotes.notes.drop()
true

> show collections
notes
system.indexes

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.