To list all collections in Mongo shell, you can use the function getCollectionNames().
The syntax is as follows −
db.getCollectionNames();
You can use another command which is collections. The syntax is as follows −
show collections;
To list all collections in Mongo, use the above two functions. The query is as follows −
> db.getCollectionNames();
Apart from the options suggested by other people:
show collections // Output every collection
show tables
db.getCollectionNames() // Shows all collections as a list
There is also another way which can be really handy if you want to know how each of the collections was created (for example, it is a capped collection with a particular size):
db.system.namespaces.find()
First you need to use a database to show all collection/tables inside it.
>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