Occasionally you want to remove old collections when they are no longer needed. Removing old collections frees up disk space and eliminates any overhead, such as indexing, associated with the collection.
To delete a collection in the MongoDB shell, you need to switch to the correct database, get the collection object, and then call the drop()
function on that object. For example, the following code deletes the newCollection
collection from the testDB
database, as shown in Figure 12.8:
use testDB
show collections
coll = db.getCollection("newCollection")
coll.drop()
show collections