在MongoDB shell中,如何列出当前使用的数据库的所有集合?


当前回答

>显示表格

它给出了与卡梅伦的答案相同的结果。

其他回答

如果有人使用Python和PyMongo:

db.list_collection_names()

> show collections

将列出当前选定DB中的所有集合,如命令行帮助(help)中所述。

在>=2.x时,您可以

db.listCollections()

在1.x上,您可以做到

db.getCollectionNames()

显示表

显示表格

or

db.getCollectionNames();

显示表

切换到数据库后,该命令通常在MongoDB shell上运行。