mongodb@ Introductory One

Source: Internet
Author: User
Tags install mongodb

To install MongoDB self-search, I offer here a GUI version similar to Navicat.

1. Database level

Show DBS #查看服务器上的数据库 [local 0.000GB]

Use test #切换到指定数据库 if test does not exist in the database, the test database will be created

DB #查看当前数据库 [test]

Db.dropdatabase ()  #删除当前使用的数据库 [{"Dropped": "Test", "OK": 1}]
2. Collection level
Db.createcollection ("book")  #新建一个名叫book的collection

Show Collections #查看当前数据库中的所有集合 () #删除名叫book的collection ("Book2") #将book renamed to Book2 ({id:1})   #在book集合上, establish an index to the ID field, 1 for ascending ()      #获取book集合上的索引 ({id:1})    #删除book集合上的索引
=============db.collection.update (criteria, objnew, Upsert, Multi) ======
Update () parameter description:
The criteria:update query condition is equivalent to the WHERE Condition clause in SQL update
Objnew:  updated object and some update operations, can be understood as set column= ' value '
Upsert: If no record of update is present, insert objnew True to insert, false does not insert
Multi:mongodb default False, update only the first record found, if this parameter is true, you can find out all the records are updated by criteria
======================================================================== ({},{$rename: {"BookName": "Bookname2"}},false,true)   #将book集合中的所有记录的bookname字段的名字修改为bookname2 ({},{$set: {"Price", "}},false,true")   #为book集合的每一条记录添加一个字段, and assigned a value of 50 ({},{"$unset": {"price": 1}},false,true)    #删除集合中的所有记录的price字段 ({"BookName": "Introduction to Algorithms", "Price": ""} ")    #向book集合中插入两条记录 ({"Bookename": "Data Structure", "Price": "$"})     #和insert一样也能插入一条记录 ()      #查询出book集合中所有的记录数

[email protected] Getting started one

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: 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.