
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
List All Databases in the Mongo Shell
To list all databases in the Mongo shell, you need to use show command. The syntax is as follows −
show dbs;
Let us implement the above syntax for MongoDB. The query is as follows −
> show dbs;
The following is the output −
admin 0.000GB config 0.000GB local 0.000GB sample 0.000GB sampleDemo 0.000GB test 0.003GB
If you create a new database in MongoDB then it won’t be present in list of databases.
Let us check the same. Create a new database −
> use studentTracker; switched to db studentTracker
Now list all the databases from Mongo shell. The query is as follows −
> show dbs;
The following is the output −
admin 0.000GB config 0.000GB local 0.000GB sample 0.000GB sampleDemo 0.000GB test 0.003GB
Look at the above sample output, the database ‘studentTracker’ is not present in database list. This is because the database is empty and it isn’t having any collection −
Note: In order to display the newly created database in the list, you need to create a collection in the new database.
Advertisements