如果要列出特定数据库的所有集合,则需要先切换数据库。查询如下-
> 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