Create a Student information sheet (at least includes: name, gender, score, age)
1. Write 15 different data
db.students.insertmany (
[
{name: "Bob", Age:16, Sex: "Male", grade:95},
{name: "Ahn", a ge:18, Sex: "Female", grade:45},
{name: "Xi", age:15, Sex: "Male", grade:75},
{name: "Bob1", age:16, Sex: "Ma Le ", grade:95},
{name:" Ahn1 ", age:18, Sex:" Male ", grade:45},
{name:" Xi1 ", age:15, Sex:" Female ", grade:55} ,
{name: "Bob2", age:16, Sex: "Female", grade:95},
{name: "Ahn2", age:18, Sex: "Male", grade:60},
{name: " Xi2 ", age:15, Sex:" Male ", grade:75},
{name:" Bob3 ", age:16, Sex:" Male ", grade:95},
{name:" Ahn3 ", age:18, S Ex: "Female", grade:45},
{name: "Xi3", age:15, Sex: "Male", grade:85},
{name: "Bob4", age:16, Sex: "Female", g RADE:95},
{name: "Ahn4", age:18, Sex: "Male", grade:45},
{name: "Xi4", age:15, Sex: "Male", grade:75}
]
)
2, query all male data (only the student's name and age)
Db.students.find ({sex: ' Male '}, {name:1, age:true, _id:0})
3. Information of students who have passed the exam (students score is greater than or equal to 60 points)
Db.students.find ({grade: {' $gte ': 60}})
4. Check the data of all 18-year-olds and 16-year-old girls
Db.students.find ({' $or ': [{sex: ' Male ', age:18}, {sex: ' Female ', Age:16}]})
5, according to the age of students to sort
Db.students.find (). Sort ({age:1})
6. Increase the age of all female students by one year
Db.students.update ({sex: ' female '}, {' $inc ': {age:1}}, {multi:true})
An instance of the increment, delete, change, and interpolate of MongoDB