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


当前回答

使用mongo shell中的以下命令:

show collections

其他回答

如果有人使用Python和PyMongo:

db.list_collection_names()

显示表

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

>显示表格

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

显示表

显示表格

or

db.getCollectionNames();

首先,您需要使用数据库来显示其中的所有集合/表。

>show dbs
users 0.56787GB
test (empty)
>db.test.help() // this will give you all the function which can be used with this db
>use users
>show tables //will show all the collection in the db