June 2014
Intermediate to advanced
696 pages
38h 52m
English
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 testDBshow collectionscoll = db.getCollection("newCollection")coll.drop()show collections
Figure 12.8 Deleting ...
Read now
Unlock full access