Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Getting database information in mongodb

    • 0
    • 2
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 493
    Comment on it

    Hello readers!

    Many time we get stuck with the query How to get the database information in Mongodb? Here below is the simple answer for this query-

    We can easily get the database information using below predefined methods:

    a) show dbs - Populate a list of all databases on the server.

    Syntax: db.showdbs
    

    b) show collections - Print a list of all collections for current database.

    Syntax: db.showCollections
    Result: collection1
                collection2
                system.indexes
    

    c) db.stats() - Returns statistics that reflect the use state of a single database.

    Syntax: db.stats(scale)
    Example: { dbStats: 1, scale: 1 }
             { dbStats: 1, scale: 1024 }
    

    -scale parameter is optional. We can scale at which to deliver results. Unless specified, this command returns all data in bytes.

    d) db.runCommand( command ) - Provides a helper to run specified database commands. This is the preferred method to issue database commands, as it provides a consistent interface between the shell and drivers. -command - A database command, specified either in document form or as a string. If specified as a string, db.runCommand() transforms the string into a document.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: