

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
To display a database in the SHOW dbs list, do we need to add collections to it?
Yes, to display a database in the list, first create a database and add collection(s), else it won’t be visible in the list. After that, use the SHOW dbs command to display the database name in the list of databases.
Following is the query to create a database −
> use webcustomertracker; switched to db webcustomertracker
Let us first create a collection with documents −
> db.first_Collection.insert({"Name":"Chris"}); WriteResult({ "nInserted" : 1 })
Following is the query to display all documents from a collection with the help of find() method −
> db.first_Collection.find();
This will produce the following output −
{ "_id" : ObjectId("5ce2760836e8b255a5eee94a"), "Name" : "Chris" }
Following is the query to display your creating database −
> show dbs;
This will produce the following output −
admin 0.002GB business 0.000GB config 0.000GB local 0.000GB main 0.000GB my 0.001GB sample 0.002GB sampleDemo 0.000GB studentSearch 0.000GB test 0.019GB university 0.000GB web 0.001GB webcustomertracker 0.000GB
- Related Questions & Answers
- Why do we need a Database
- Display collections in a particular MongoDB database?
- How to list all the Collections in a MongoDB database using Java?
- What do we need to do to join Indian Army?
- How to list all collections from a particular MongoDB database?
- What is BGP and why do we need it?
- Do we need to use semicolons in JavaScript?
- MongoDB difference between show dbs and show databases?
- When a DB2 subprogram undergoes changes, do we need to BIND it with its program?
- Why do we need to change the delimiter for creating a trigger?
- Why SHOW DBS does not show my databases in MongoDB?
- When overriding clone method, why do we need to declare it as public in Java?
- Why do we need KDD?
- How do we add a menu list in HTML?
- Why do we need Good Manners?
Advertisements