How to remove a MySQL collection named 'group'?

The group is a reserved method name in MongoDB. While you can create a collection named "group", it requires special syntax to access. To remove such a collection, use getCollection('group').drop() method.

Syntax

db.getCollection('group').drop();

Create Sample Collection

Let us first create a collection named "group" with some sample documents ?

db.createCollection('group');
{ "ok" : 1 }
db.getCollection('group').insertMany([
    {"StudentName": "Chris"},
    {"StudentName": "Robert"}
]);
{
    "acknowledged" : true,
    "insertedIds" : [
        ObjectId("5cb80fe9623186894665ae3c"),
        ObjectId("5cb80fef623186894665ae3d")
    ]
}

Verify Collection Data

Display all documents from the collection using find() method ?

db.getCollection('group').find();
{ "_id" : ObjectId("5cb80fe9623186894665ae3c"), "StudentName" : "Chris" }
{ "_id" : ObjectId("5cb80fef623186894665ae3d"), "StudentName" : "Robert" }

Remove the Collection

Now remove the collection named "group" using the drop() method ?

db.getCollection('group').drop();
true

Key Points

  • Use getCollection() method to access collections with reserved names like "group".
  • The drop() method permanently removes the entire collection and all its documents.
  • Returns true if the collection was successfully dropped.

Conclusion

Collections with reserved names like "group" require getCollection() method for access. Use db.getCollection('group').drop() to permanently remove such collections from your MongoDB database.

Updated on: 2026-03-15T00:46:49+05:30

146 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements