主要内容

dropCollection

下降MongoDB集合

dropCollection函数将在未来的版本中被删除。使用dropCollectionMongoDB的功能®而不是c++接口。

描述

例子

dropCollection (康涅狄格州集合通过使用MongoDB连接从MongoDB删除一个现有的集合。

例子

全部折叠

连接MongoDB并删除一个集合。

创建到数据库的MongoDB连接mongotest.这里是数据库服务器dbtb01使用端口号托管该数据库27017

服务器=“dbtb01”;端口= 27017;dbname =“mongotest”;康涅狄格州= mongo(服务器、端口dbname)
conn = mongo with properties: Database: 'mongotest' UserName: " Server: {'dbtb01'} Port: 27017 CollectionNames: {' airlinesal ', 'employee', 'largedata'…and 3 more} TotalDocuments: 23485919

康涅狄格州蒙戈包含MongoDB连接的对象。对象属性包含有关连接和数据库的信息。

  • 数据库名称为mongotest

  • 用户名为空。

  • 数据库服务器为dbtb01

  • 端口号为27017

  • 这个数据库包含六个文档集合。前三个集合名是airlinesmall员工,largedata

  • 这个数据库包含23,485,919个文档。

检查MongoDB连接。

isopen(康涅狄格州)
逻辑1

数据库连接成功,因为isopen函数返回1.否则,数据库连接将关闭。

属性删除集合之前,在数据库中显示集合CollectionNames财产。

conn.CollectionNames
ans = 1×7 cell array列1到5 {' airlinsmall '} {'employee'} {'largedata'} {'nyctaxi'} {'product'}列6到7 {'restaurants'} {'taxidata'}

使用MongoDB连接从数据库中删除一个现有的集合。指定集合名称taxidata

收集=“taxidata”;dropCollection(康涅狄格州、收集)

属性在数据库中再次显示集合CollectionNames财产。数据库不再包含集合taxidata

conn.CollectionNames
ans = 1×7 cell array列1到5 {' airlinsmall '} {'employee'} {'largedata'} {'nyctaxi'} {'product'}列6 {'restaurants'}

关闭MongoDB连接。

关上(康涅狄格州)

输入参数

全部折叠

MongoDB连接,指定为蒙戈对象。

集合名称,指定为字符串标量。

例子:“taxidata”

数据类型:字符串

介绍了R2017b