drop() 方法在使用时不需要带有任何参数,并且在使用参数调用时会产生错误,该方法的语法格式如下:
db.collection_name.drop()
其中 collection_name 为要删除的集合名称,方法调用成功会返回 true,否则返回 false。【示例】查看数据库“bianchengbang”中的所有集合,并删除其中的集合“mycol”。
> show tables mycol user website > db.mycol.drop() true至此集合“mycol”就成功删除了,您可以再次使用
show tables 命令来查看数据库中的集合。> show tables user website