Để xóa tên tập hợp số, hãy sử dụng cú pháp sau
db.getCollection("yourNumericCollectionName").drop(); Đầu tiên, tạo một bộ sưu tập số. Sau đây là truy vấn
> db.createCollection("2536464");
{ "ok" : 1 } Bây giờ hãy chèn một số tài liệu trong bộ sưu tập trên. Sau đây là truy vấn
> 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")
} Sau đây là truy vấn để hiển thị tất cả các tài liệu từ một bộ sưu tập với sự trợ giúp của phương thức find ()
> db.getCollection("2536464").find().pretty(); Điều này sẽ tạo ra kết quả sau
{ "_id" : ObjectId("5ca254a46304881c5ce84b8e"), "Record" : 1 }
{ "_id" : ObjectId("5ca254a76304881c5ce84b8f"), "Record" : 2 }
{ "_id" : ObjectId("5ca254a96304881c5ce84b90"), "Record" : 3 } Sau đây là truy vấn để xóa tên bộ sưu tập số
> db.getCollection("2536464").drop(); Điều này sẽ tạo ra kết quả sau
True
Bây giờ, tên bộ sưu tập số đã được xóa thành công.