MONGODB Basic Class SQL command Basic Learning

Source: Internet
Author: User

  1. Landing

    MONGO 192.168.0.134:27017

  2. View Gallery

    Show DBS

  3. Building a library

    Use test

    Db.createcollections ("command")

  4. To view a table in a library

    Show collections;

  5. Insert statement

    Db.command.insert ({name: "SSH", decriptions: "This is login Remote host command"})

    Db.command.insert ({name: "Ifconfig", Decriptions: "It can search for IP"})

    Db.user.insert ({name: "Zhangsan", Age: "20"})

    Db.user.insert ({name: "Lisi", Age: "21"})

    Db.user.insert ({name: "Zhaowu", Age: "30"})

    Db.user.insert ({name: "Wangliu", Age: "55"})

  6. Query statements

    Db.command.find ()


  7. Conditional query

    Db.command.find ({name: "Ifconfig"}) query JSON for name=/ifconfig/

    Db.command.find (). Limit (2) View only the first two lines

    Db.user.find (' this.age> ' 30 ")

    Db.user.find (). Sort ({age:1}) ascending query

    Db.user.find (). Sort ({age:-1}) descending query

  8. Delete a library

    Use test

    Db.dropdatabase ()

  9. Delete a table

    Db.command.drop ()

  10. Delete a field

    Db.user.remove ({name= "Zhangsan"})

  11. Conditional delete

    Db.user.remove ({' this.age> "30"})

  12. Number of rows of statistics

    Db.user.count ()

  13. UPDATE statement

    Db.user.update ({name: "Lisi"},{$set: {age: "21"}})

This article is from the "Common Documents" blog, so be sure to keep this source http://yujianglei.blog.51cto.com/7215578/1603861

MONGODB Basic Class SQL command Basic Learning

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.