Some beginner's questions about MongoDB

Viewed 13131

I'm a beginner with MongoDB and I've some questions:

  1. When I'm connected to Mongo, and i execute show dbs I see 2 databases: admin and local. What's their role? Then if I execute an insert command like db.foo.insert({"value":"mongo"}), the test database appears. Why? How can i specify a custom name for a database?

  2. With show dbs I get the databases (somehow like show databases in sql), how can I then list the collections inside a database (I would use show tables in sql)?

  3. When executing a command, the MongoDB tutorial always uses the db object. Is it the main object (a sort of "connection" object) that has to used for executing commands or it's something else?

Thanks!

1 Answers
Related