Cette page n'est pas encore disponible dans votre langue. Nous nous efforçons d'ajouter d'autres langues. Nous vous remercions de votre compréhension.

On this page

Show all

Creating and Managing Databases

Updated on 2022-09-21 GMT+08:00

For details about the rules of the write/update and delete commands, see Write/Update and Delete.

Procedure

  1. Create database info.

    use info

    Enter db. If the following information is displayed, the database is opened.

    info

  2. Insert a data record into the database.

    db.user.insert({"name": "joe"})

    CAUTION:

    Implicit collection is a collection that is created after data is inserted. To create a collection (table), you must insert a document (record) to make the collection creation take effect.

  3. View the database

    To view all databases, run the following command:

    show dbs

    The command output is as follows:

    admin   0.000GB
    config  0.000GB
    info    0.000GB
    local   0.083GB

  4. Delete the database. Run the following command to delete the info database:

    db.dropDatabase()

    The database is deleted if the following information is displayed:

    {"dropped" : "info", "ok" : 1}

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback