
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
What is the BSON query for the command 'show dbs' (list of databases) in MongoDB?
The command you can use is db.runCommand(). Let us first switch to admin −
> use admin switched to db admin
Now, run the command −
> db.runCommand({listDatabases : 1})
This will produce the following output −
{ "databases" : [ { "name" : "admin", "sizeOnDisk" : 2375680, "empty" : false }, { "name" : "app", "sizeOnDisk" : 32768, "empty" : false }, { "name" : "business", "sizeOnDisk" : 417792, "empty" : false }, { "name" : "config", "sizeOnDisk" : 106496, "empty" : false }, { "name" : "local", "sizeOnDisk" : 81920, "empty" : false }, { "name" : "main", "sizeOnDisk" : 184320, "empty" : false }, { "name" : "my", "sizeOnDisk" : 753664, "empty" : false }, { "name" : "ok", "sizeOnDisk" : 1024000, "empty" : false }, { "name" : "sample", "sizeOnDisk" : 3297280, "empty" : false }, { "name" : "sampleDemo", "sizeOnDisk" : 352256, "empty" : false }, { "name" : "studentSearch", "sizeOnDisk" : 262144, "empty" : false }, { "name" : "test", "sizeOnDisk" : 32944128, "empty" : false }, { "name" : "university", "sizeOnDisk" : 229376, "empty" : false }, { "name" : "web", "sizeOnDisk" : 3661824, "empty" : false }, { "name" : "webcustomertracker", "sizeOnDisk" : 32768, "empty" : false } ], "totalSize" : 45756416, "ok" : 1 }
- Related Articles
- MongoDB difference between show dbs and show databases?
- Why SHOW DBS does not show my databases in MongoDB?
- What is the synonym statement of SHOW DATABASES with the help of which we can see the list of MySQL databases?
- Get the real document BSON size in MongoDB?
- How to list databases vertically in MySQL command line?
- How to get the list of all the MongoDB databases using java?
- Command to show the database currently being used in MongoDB?
- To display a database in the SHOW dbs list, do we need to add collections to it?
- Query for values (not objects) in list with MongoDB
- MongoDB profiler output: What is the “command” operation?
- Does MongoDB getUsers() and SHOW command fulfil the same purpose?
- Display databases in MongoDB
- Which MySQL query can be used with the help of which we can see the list of MySQL databases?
- Return list of databases in MySQL?
- How to query on list field in MongoDB?

Advertisements