Basic Statements in MongoDB

After my late post about mongoDB, i will share about basic statements in mongoDB. There are several basic statement in mongoDB, such as:

  1. show dbs. This statement was used to show existing database in mongoDB. See the picture for further information.
    show dbs

    show dbs Statement

    For your information, percobaan is name of database that exists in my mongoDB.

  2. use database_name. This statement was used to choose database that you want to access. After use this statement, you can define or manipulate the contents of that database. For example, if i want to use percobaan as current database, i will type use percobaan. See the picture for further information.
    use database Statement

    use database Statement

    Beside that, use statement can be used to create new database in mongoDB but that database will be create if you have already insert new document (as known as table in RDBMS). If you want to create new database, type use statement followed by name of database (type name that wasn’t already exist before).

  3. db. This statement was used to check what database which is running. See the picture for further information.

    db Statement

    db Statement

  4. show collections. This statement was used to show documents in a database. See the picture for further information.

    show collections Statement

    show collections Statement

  5. help. This statement was used to show several statements in mongoDB that can be used by you. This statement can has prefix (such as: db.help) if you’ve already known several statements but you can’t complete it. See the picture for further information.
    help Statement

    help Statement

    Ok buddy, those are several basic statement that can open your mind (maybe just a little but not problem) about mongoDB. For the next post, i will share about RoboMongo, a software that can make your sight about mongoDB more fun. Bye…

 

 

Leave a comment