If you want to list all collections from a particular database then you need to switch the database first. The query is as follows −
> use sample; switched to db sample > db.getCollectionNames();
The following is the output −
[ "copyThisCollectionToSampleDatabaseDemo", "deleteDocuments", "deleteDocumentsDemo", "deleteInformation", "employee", "internalArraySizeDemo", "sourceCollection", "updateInformation", "userInformation" ]
An alternate query can be the following −
> show collections;
The following is the output −
copyThisCollectionToSampleDatabaseDemo deleteDocuments deleteDocumentsDemo deleteInformation employee internalArraySizeDemo sourceCollection updateInformation userInformation