How to Show the Tables or Collections in a Mongo Database

Login into MongoDBs shell

root@avalon:/# mongo
MongoDB shell version v4.2.22
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("c16894d6-3307-4239-afdc-4856bcd3e5cd") }
MongoDB server version: 4.2.22

>                                       

Get the list of databases in the server.

> show dbs
admin   0.000GB
avalon  0.268GB
config  0.000GB
local   0.000GB

Select a database.

> use avalon
switched to db avalon                 

Show the tables in the database using command show tables or show collections.

> show tables
accounts
contents
distributed
masterdao
playlists
proposals
state    
> show collections
accounts
contents
distributed
masterdao
playlists
proposals
state

Leave a Comment

Required fields are marked *