Mongodb Show Collection - MongoDB Tutorial




Mongodb Show Collection

MongoDb

  • In mongoDB “show” command is used to display the available data like database, collection etc.

Syntax (Show Database) :

show db  

Here in this syntax , we display the available data base.

Syntax (Show Collection) :

SHOW INDEXES [IN <database_name>] [FOR COLLECTION <collection_name>]
  • List all of the indexes for the indicated database and collection.
  • If collection_name is not specified, this command will list all the indexes in the indicated database.
  • If database_name is not specified, this command defaults to the current database.

Syntax (Show Index Fields) :

SHOW INDEXFIELDS IN collection_name [IN <database_name>] [FOR INDEX <index_name>]
  • List all of the index fields for the indicated database, collection and index.
  • If database_name is not specified, this command defaults to the current database.

Syntax (Show Users) :

SHOW USERS [IN <database_name>] [FOR USER <user_name>]
  • Here in this syntax SHOW USERS will List the users of the indicated database and describe their USER_PERMISSIONS.
  • If database_name is not specified, then this command defaults to the current database.

Syntax (Show Roles) :

SHOW ROLES [IN <database_name>] [FOR USER <role_name>]
  • Here in this syntax SHOW ROLES will List the roles of the user in the current database or the specified database. This is equivalent to MongoDB's db.runCommand({rolesInfo}) command.
  • The following columns are displayed for SHOW ROLE:
    • role,
    • db,
    • isBuiltin,
    • roles,
    • inheritedRoles,
    • privileges & inherited Privileges

Syntax (show RS_Status) :

SHOW RS_STATUS
  • Here in this statement is used for list out of the current database or the specified database. This is equivalent to MongoDB's

Syntax (show SH_Status) :

SHOW SH_STATUS
  • Here we display the clustered & data sharing document only visible.
MongoDb

  1. Here in this statement “show collections” we have printed the list of collections in the database.


Related Searches to Mongodb Show Collection - MongoDB Tutorial