如何从MongoDB中删除数字集合?
为了删除数字集合名称,请使用以下语法
db.getCollection("yourNumericCollectionName").drop();首先,创建一个数字集合。以下是查询
> db.createCollection("2536464");
{ "ok" : 1 }现在,在上述集合中插入一些文档。以下是查询
> 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")
}以下是在find()方法的帮助下显示集合中所有文档的查询
> db.getCollection("2536464").find().pretty();这将产生以下输出
{ "_id" : ObjectId("5ca254a46304881c5ce84b8e"), "Record" : 1 }
{ "_id" : ObjectId("5ca254a76304881c5ce84b8f"), "Record" : 2 }
{ "_id" : ObjectId("5ca254a96304881c5ce84b90"), "Record" : 3 }以下是删除数字集合名称的查询
> db.getCollection("2536464").drop();这将产生以下输出
True
现在,数字集合名称已成功删除。
热门推荐
1 狗狗下楼训练
3 狗狗训练头盔
6 狗狗训练机构
7 训练狗狗步骤
9 狗狗能训练
10 狗狗基本动作训练方法
11 怎么训练狗狗叼饭盆
12 狗狗一岁了还能训练吗
13 训练狗狗的
14 宁波狗狗训练
15 训练狗狗拉屎
16 教狗狗训练
17 狗狗要怎么训练上厕所
18 狗狗靠的训练