Operation Select Database Insert Record
Operation Select Database Insert Record
SELECT DATABASE
INSERT RECORD
SELECT
WHERE CONDITION
And | Or
In
count()
ORDER BY
UPDATE
DELETE
DROP
TOP
DISTINCT
EMBEDED DOCUMENT AND DOT NOTATION : DOCUMENT WITHIN DOCUMENT AND TO ACCES THAT WE USE .
db.Employee.insert
(
{
Name:{FirstName:"Santosh",LastName:"Alex"},Age:37,Email:"[email protected]",Address:"USSR",Interest:
}
)
db.Employee.insert
(
{
Name:{FirstName:"Alex",LastName:"Smith"},Age:37,Email:"[email protected]",Address:"USSR",Interest:["D
}
)
db.Employee.find({"Name.FirstName":"Santosh"})
Mongodb is Schema Less ??? : No any predefined stru , Any document can contain any values
SQL SERVER
USE TEST
db.Employee.insert
(
{
Name:'Robin',Age:27,Email:"[email protected]",Address:"Delhi",Interest:["Cooking","Music"]
}
)
db.Employee.insert
(
{
Name:'Jone',Age:57,Email:"[email protected]",Address:"Boston",Interest:["Driving","Music"]
}
)
db.Employee.insert
(
{
Name:'Allen',Age:37,Email:"[email protected]",Address:"USSR",Interest:["Driving","Music"]
}
)
CUMENT AND DOT NOTATION : DOCUMENT WITHIN DOCUMENT AND TO ACCES THAT WE USE .
db.Employee.insert
Name:{FirstName:"Santosh",LastName:"Alex"},Age:37,Email:"[email protected]",Address:"USSR",Interest:["Driving","Music"]
db.Employee.insert
Name:{FirstName:"Alex",LastName:"Smith"},Age:37,Email:"[email protected]",Address:"USSR",Interest:["Driving","Music"]
db.Employee.find({"Name.FirstName":"Santosh"})
hema Less ??? : No any predefined stru , Any document can contain any values
db.Employee.insert
(
{
Name:{FirstName:"Santosh",LastName:"Alex"},Age:37,Email:"[email protected]",Address:"USSR",Interest:["Driving","Music"]
}
)
db.Employee.insert
(
{
Name:{FirstName:"Alex",LastName:"Smith"},Age:37,Email:"[email protected]",Address:"USSR",Interest:["Driving","Music"]
}
)
db.Employee.insert
(
{
Name:"Scott",Salary:"5000"
}
)
String : 2
Double : 1
Embeded : 3
Date : 9
Null : 10
Boolean : 8
Regular Expression : 11
Array : 4
MONGODB
USE TEST
db.student.insert
(
{"_id":1,"Name":"santosh","Email":"[email protected]","mobile":"9626262","Address":"London"}
)
db.student.find()
db.student.find({},{"Name":1})
db.student.find({},{"Name":1,"mobile":true,"_id":0}) (1 : Has to display , 0 : Hide )
db.student.find({Name:"santosh"})
db.student.find({_id:{$gt:2}})
db.student.find({_id:{$gte:2}})
db.student.find({_id:{$lt:2}})
db.student.find({$and :[{Name:"santosh"},{mobile:'9626262'}]})
db.student.find({$or :[{Name:"santosh"},{mobile:'9626262'}]})
db.student.find({_id:{$in:[1,2,3]}})
db.student.find().count()
db.student.find().sort({Name:1}) (Ascending)
db.student.find().sort({Name:-1}) (Descending)
db.student.update({_id:1},{$set :{mobile:'73737',Address:'USA'}})
UPSERT (UPDATE + INSERT) (IF ID IS THERE ..WILL UPDATE OTHERWISE GO FOR INSERT)
db.student.update({_id:1},{$set :{mobile:'73737',Address:'USA'}},{upsert:true})
MULTI (WILL GO FOR MULTIPLE DOCUMENT UPDATE, BY DEFAULT ONLY ONE DOC WILL UPDATED)
db.student.update({_id:1},{$set :{mobile:'73737',Address:'USA'}},{multi:true})
db.student.remove({_id:1})
db.student.remove({})
db.student.drop()
LIMIT
db.student.find().limit(2)
SKIP
db.student.find().skip(2).limit(2)
db.student.distinct("name)
est:["Driving","Music"]
",Interest:["Driving","Music"]
nterest:["Driving","Music"]