Creating and Managing Databases
For details about the rules of the write/update and delete commands, see Write/Update and Delete.
Procedure
- Create database info.
use info
Enter db. If the following information is displayed, the database is opened.
info
- Insert a data record into the database.
db.user.insert({"name": "joe"})
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.
- 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
- 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
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.