

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to drop a numeric collection from MongoDB?
In order to remove the numeric collection name, use the following syntax
db.getCollection("yourNumericCollectionName").drop();
First, create a numeric collection. Following is the query
> db.createCollection("2536464"); { "ok" : 1 }
Now insert some documents in the above collection. Following is the query
> db.getCollection("2536464").insertOne({"Record":1}); { "acknowledged" : true, "insertedId" : ObjectId("5ca254a46304881c5ce84b8e") } > db.getCollection("2536464").insertOne({"Record":2}); { "acknowledged" : true, "insertedId" : ObjectId("5ca254a76304881c5ce84b8f") } > db.getCollection("2536464").insertOne({"Record":3}); { "acknowledged" : true, "insertedId" : ObjectId("5ca254a96304881c5ce84b90") }
Following is the query to display all documents from a collection with the help of find() method
> db.getCollection("2536464").find().pretty();
This will produce the following output
{ "_id" : ObjectId("5ca254a46304881c5ce84b8e"), "Record" : 1 } { "_id" : ObjectId("5ca254a76304881c5ce84b8f"), "Record" : 2 } { "_id" : ObjectId("5ca254a96304881c5ce84b90"), "Record" : 3 }
Following is the query to remove numeric collection name
> db.getCollection("2536464").drop();
This will produce the following output
True
Now the numeric collection name has been removed successfully.
- Related Questions & Answers
- How to drop a collection in MongoDB?
- How to drop a MongoDB Collection using Java?
- How to get array from a MongoDB collection?
- How to remove duplicates from MongoDB Collection?
- How to delete documents from a collection in MongoDB?
- How to retrieve documents from a collection in MongoDB?
- Retrieve data from a MongoDB collection?
- How to drop a database in MongoDB?
- How can I drop a collection in MongoDB with two dashes in the name?
- How to get unique values from MongoDB collection?
- How do I drop a MongoDB database from the command line?
- How to delete all the documents from a collection in MongoDB?
- MongoDB query to pull array element from a collection?
- MongoDB query to remove entire data from a collection
- How to read a specific key-value pair from a MongoDB collection?
Advertisements