Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    MongoDB - Drop Collection

    For dropping a collection in MongoDB, you have to make use of the collection.drop() method. This will eliminate the collection from the database completely and will not leave any indexes that are connected to this drop collection. It is also to be noted that, this collection dropping method has no argument in it and will pop up with errors in case arguments are passed. All the indexes associated with the collection gets dropped once this method is executed.

    The syntax for using this method is:

    Syntax:

    db.collection_name.drop()

    Here is an example that is showing the use of the drop() method:

    Continuing from the example in the previous lesson where you have created a collection inside the my_project_db database. Now use this database to remove or drop the movie collection and see the changes:

    Example:

    use my_project_db
    db.movie.drop()
    show collections

    Output:



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.