如何列出特定 MongoDB 数据库中的所有集合?
如果你想列出特定数据库中的所有集合,则需要首先切换数据库。查询如下 −
> use sample; switched to db sample > db.getCollectionNames();
输出如下 −
[ "copyThisCollectionToSampleDatabaseDemo", "deleteDocuments", "deleteDocumentsDemo", "deleteInformation", "employee", "internalArraySizeDemo", "sourceCollection", "updateInformation", "userInformation" ]
备用查询可以如下 −
> show collections;
输出如下 −
copyThisCollectionToSampleDatabaseDemo deleteDocuments deleteDocumentsDemo deleteInformation employee internalArraySizeDemo sourceCollection updateInformation userInformation
广告