MongoDB Management client behind is a JavaScript Shell, is a complete JavaScript interpreter, with "MONGO" command log in;
After entering into the default test database, you can view the current connected database with the DB command:
[[email protected] ~]# MONGO MongoDB shell version:2.6.6 connecting to:test > DB Test >
Enter Help to find the available commands:
> help db.help () help on db methods Db.mycoll.help () help on collection methods sh.help () harding helpers Rs.help () replica set helpers help admin administrative help help connect connecting to a db help help keys key shortcuts help misc misc things to know help mr mapreduceshow dbs show database names show collections show collections in current database show users show users in current database show profile show most recent system.profile entries with time >= 1ms show logs show the accessible logger names show log [name] prints out the last segment of log in memory, ' Global ' is default use <db_name> set current database db.foo.find () list objects in collection foo db.fOo.find ( { a : 1 } ) list objects in foo where a == 1 it result of the last line Evaluated; use to further iterate dbquery.shellbatchsize = x set default number of items to display on shell exit quit the mongo shell >
MongoDB does not display commands to create a database and delete commands for the database, create a database with use;
Create a database of blogs:
> Use blog switched to DB blog
Insert a collection and document:
> Db.post.insert ({"Geeting": 3}); Writeresult ({"ninserted": 1})
To view the databases and collections created:
> Show DBS admin (empty) blog 0.078GB local 0.078GB > show Collections Post system.indexes
Deleting a database
> Db.dropdatabase (); {"Dropped": "blog", "OK": 1} > Show DBS admin (empty) Local 0.078GB
This article is from the "Margin with Wish" blog, please be sure to keep this source http://281816327.blog.51cto.com/907015/1598286
MongoDB Learning Note 4 MongoDB manages the client and creates the database