Getting database information


Getting database information

If you want to see the database list, use the showdbs command. The database (mydb) you created is not in the list. To view the database, you need to insert at least one document in the database. In MongoDB, the default database is tested.

The use Command

MongoDB uses DATABASE_NAME is used to create a database. The command will create a new database. Otherwise, if it doesn't exist, it will return the existing database.

The dropDatabase() Method

MongoDB db.dropDatabase() command is used to drop a existing database.
This will delete the selected database. If you have not selected any database, it will delete the default 'test' database.

listDatabases

The listDatabases command provides a list of all existing databases and basic statistics about them. The listDatabases must run against the admin database.