show dbs — MongoDB Technical Interview Questions & Answers
Lists all databases on the connected server.
show dbs
- Simple meaning: show dbs lists databases on the server (empty DBs with no collections may not show).
- How to use: in mongosh type show dbs (or db.adminCommand("listDatabases")).
- Try this: use college then insertOne, then show dbs — college should appear.
- Common mistake: SQL SHOW DATABASES; with a semicolon as if this were MySQL.
- Interview tip: Shell helper, not a collection query.
Technical Interview Tip: show dbs after the first write.
Code Examples for show dbs
show dbs — working example
show dbs
// or:
db.adminCommand({ listDatabases: 1 })show dbs lists databases on the server (empty DBs may be hidden until they hold data).
How to Explain show dbs to an Interviewer
What does show dbs do?
Lists databases on the server