- Reference >
- Database Commands >
- Diagnostic Commands >
- listDatabases
listDatabases¶
On this page
Definition¶
-
listDatabases¶ The
listDatabasescommand provides a list of all existing databases along with basic statistics about them:The value (e.g.
1) does not affect the output of the command.The
listDatabasesmust run against theadmindatabase, as in the following example:
Output¶
The following is an example of a listDatabases result:
listDatabases returns a document that contains:
- A field named
databaseswhose value is an array of documents, one document for each database. Each document contains:- A
namefield with the database name - A
sizeOnDiskfield with the total size of the database file on disk in bytes, and - An
emptyfield specifying whether the database has any data. - For sharded clusters, a
shardsfield that specifies the shards and the size in bytes of the database on disk for each shard.
- A
- A field named
totalSizewhose value is the sum of all thesizeOnDiskfields. - A field named
totalSizeMbwhose value istotalSizein megabytes. - A field named
okwhose value determines the success of thelistDatabasescommands.1indicates success.
See also