Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to remove a MySQL collection named 'group'?
The group is a type of method in MongoDB. It shouldn’t be created as a collection name. Even if you created it, you can easily remove it using getCollection('group').drop();). Let us first create a collection with documents −
> db.createCollection('group');
{ "ok" : 1 }
> db.getCollection('group').insertOne({"StudentName":"Chris"});
{
"acknowledged" : true,
"insertedId" : ObjectId("5cb80fe9623186894665ae3c")
}
> db.getCollection('group').insertOne({"StudentName":"Robert"});
{
"acknowledged" : true,
"insertedId" : ObjectId("5cb80fef623186894665ae3d")
}
Following is the query to display all documents from the collection with the help of find() method −
> db.getCollection('group').find().pretty();
This will produce the following output −
{ "_id" : ObjectId("5cb80fe9623186894665ae3c"), "StudentName" : "Chris" }
{ "_id" : ObjectId("5cb80fef623186894665ae3d"), "StudentName" : "Robert" }
Following is the query to remove the collection named ‘group’ −
> db.getCollection('group').drop();
This will produce the following output −
True
Advertisements
