MongoDB Learning Note 4 MongoDB manages the client and creates the database

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.