Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

List all available databases.

Example


Code Block
SHOW DATABASES

...



Back to top

SHOW COLLECTIONS

...

The NAMES_ONLY option retrieves the collection name only and the storage data is not included in the result set.

Example


Code Block
SHOW COLLECTIONS IN statistics

...


Back to top

SHOW VIEWS

SHOW VIEWS [IN <database_name>] [FOR VIEW <view_name>] [NAMES_ONLY] New in 19.0

...

The NAMES_ONLY option retrieves the view name only and the options data is not included in the result set.

Example


Code Block
SHOW VIEWS IN statistics

...


Back to top

SHOW FIELDS

SHOW FIELDS IN <collection_name> [IN <database_name>]

...

If database_name is not specified, this command defaults to the current database.

Example


Code Block
SHOW FIELDS IN baseballstats IN statistics

...


Back to top

SHOW INDEXES

SHOW INDEXES [IN <database_name>] [FOR COLLECTION <collection_name>]

...

If database_name is not specified, this command defaults to the current database.

Example


Code Block
SHOW INDEXES IN statistics FOR COLLECTION baseballstats

...



Back to top

SHOW INDEXFIELDS

...

If database_name is not specified, this command defaults to the current database.

Example


Code Block
SHOW INDEXFIELDS IN baseballstats IN statistics FOR INDEX batter_id_index

...



Back to top

SHOW USERS

SHOW USERS [IN <database_name>] [FOR USER <user_name>]

...

If database_name is not specified, this command defaults to the current database.

Example


Code Block
SHOW USERS IN statistics

...


SHOW ROLES

SHOW ROLES [IN <database_name>] [FOR USER <role_name>]

...

If database_name is not specified, this command defaults to the current database. The following columns are displayed for SHOW ROLE: role, db, isBuiltin, roles, inheritedRoles, privileges, inheritedPrivileges

Info

The SHOW ROLES command is only available in MongoDB 2.6 and newer.

Example


Code Block
SHOW ROLES IN mydatabase

...

Example


Code Block
SHOW ROLES FOR ROLE myrole

...




Back to top

SHOW STATUS

SHOW STATUS

Display server status. This is equivalent to the MongoDB's db.serverStatus() command.

Info

The SHOW STATUS command will only work if you are an "admin" user. In MongoDB version 2.2, you need to be able to log in to the "admin" database. In MongoDB version 2.4, you need to have the clusterAdmin role in the "admin" database.

Example


Code Block
SHOW STATUS

...



Back to top

SHOW RS_STATUS

...

The SHOW RS_STATUS command will only work if you are an "admin" user. In MongoDB version 2.2, you need to be able to log in to the "admin" database. In MongoDB version 2.4, you need to have the clusterAdmin role in the "admin" database.

Example


Code Block
SHOW RS_STATUS

...



Back to top

SHOW SH_STATUS

...

The SHOW SH_STATUS command will only work if you are an "admin" user. In MongoDB version 2.2, you need to be able to log in to the "admin" database. In MongoDB version 2.4, you need to have the clusterAdmin role in the "admin" database.

Example


Code Block
SHOW SH_STATUS

...



Back to top