Landing
MONGO 192.168.0.134:27017
View Gallery
Show DBS
Building a library
Use test
Db.createcollections ("command")
To view a table in a library
Show collections;
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"})
Query statements
Db.command.find ()
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
Delete a library
Use test
Db.dropdatabase ()
Delete a table
Db.command.drop ()
Delete a field
Db.user.remove ({name= "Zhangsan"})
Conditional delete
Db.user.remove ({' this.age> "30"})
Number of rows of statistics
Db.user.count ()
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