Enter, view, use
Enter MongoDB show Dbsuse MyDatabase Show collections db["mycol"].find ({},{_id : 0,name:1}) #
db["MyCol"].inseret ({"Key": "Value", Title: "Tutorial", Name: "Jkmiao"})
MongoDB syntax compare with existing relational database SQL syntax Db.test.find ({'name':'Foobar'}) <==> SELECT * fromTest where name='Foobar'Db.test.find ()<==> SELECT * fromTestdb.test.find ({'ID':). Count () <==> Select COUNT (*) fromTest where id=10db.test.find (). Skip (). Limit (<==> select *) fromTest Limit 10,20Db.test.find ({'ID':{$inch: [25,35,45]}}) <==> select * fromTest where IDinch(25,35,45) Db.test.find (). Sort ({'ID': -1}) <==> SELECT * fromTest ORDER by IDdescdb.test.distinct ('name',{'ID': {$lt:}}) <==> select DISTINCT (name) fromTestwhere id<20Db.test.group ({key:{'name': true},cond:{'name':'Foo'},reduce:function (Obj,prev) {prev.msum+=obj.marks;},initial:{msum:0}}) <==> select Name,sum (Marks) fromTestgroup by name Db.test.find ('this.id<20', {name:1}) <==> select name fromTest whereid<20Db.test.insert ({'name':'Foobar',' Age':) <==>insertinto Test ('name',' Age') VALUES ('Foobar', 25) Db.test.remove ({})<==> Delete * fromTestdb.test.remove ({' Age':) <==> Delete test where age=20Db.test.remove ({' Age': {$lt:}}) <==> elete test where age<20Db.test.remove ({' Age': {$lte:}}) <==> delete test where age<=20Db.test.remove ({' Age': {$gt:}}) <==> delete test where age>20Db.test.remove ({' Age': {$gte:}}) <==> delete test where age>=20Db.test.remove ({' Age': {$ne:}}) <==> delete test where age!=20db.test.update ({'name':'Foobar'},{$set: {' Age': +}) <==> update test set age=36 where name='Foobar'db.test.update ({'name':'Foobar'},{$inc: {' Age': 3}) <==> Update test set age=age+3 where name='Foobar'
Comparison between MongoDB syntax and existing relational database SQL syntax