- Reference >
- Database Commands >
- Diagnostic Commands >
- listDatabases
listDatabases¶
On this page
Definition¶
-
listDatabases
¶ The
listDatabases
command 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
listDatabases
must run against theadmin
database, as in the following example:
Output¶
The following is an example of a listDatabases
result:
listDatabases
returns a document that contains:
- A field named
databases
whose value is an array of documents, one document for each database. Each document contains:- A
name
field with the database name - A
sizeOnDisk
field with the total size of the database file on disk in bytes, and - An
empty
field specifying whether the database has any data. - For sharded clusters, a
shards
field that specifies the shards and the size in bytes of the database on disk for each shard.
- A
- A field named
totalSize
whose value is the sum of all thesizeOnDisk
fields. - A field named
totalSizeMb
whose value istotalSize
in megabytes. - A field named
ok
whose value determines the success of thelistDatabases
commands.1
indicates success.
See also