mongdb???????????????
???????????? ???????[ 2013/8/7 10:30:48 ] ????????
???????????????????????????
????1 show dbs – List all databases.
????2 use db_name – Switches to db_name.
????3 show collections – List all tables in the current selected database.
????1 ???DBS -?г????е??????
????2 ???DB_NAME -????DB_NAME??
????3 ????? -?г??????????????е????б??
???????
??????????MongoDB?У??????SQL ???
????4. Insert A Record
?????????????????
?????????????????????db.tablename.save db.tablename.insert??{????}????{????}?? ????????????????????MongoDB???????????
> db.users.save({username:"google"??password:"google123"})
> db.users.find()
{ "_id" : ObjectId("504f45cd17f6c778042c3c07")?? "username" : "mkyong"?? "password" : "123456" }
{ "_id" : ObjectId("504f48ea17f6c778042c3c0a")?? "username" : "google"?? "password" : "google123" }
?????塢??????
???????????????????{???}??{$????{???}} db.tablename.update?? ??????????????У??????????????“mkyong”???????
> db.users.update({username:"mkyong"}??{$set:{password:"hello123"}})
> db.users.find()
{ "_id" : ObjectId("504f48ea17f6c778042c3c0a")?? "username" : "google"?? "password" : "google123" }
{ "_id" : ObjectId("504f45cd17f6c778042c3c07")?? "password" : "hello123"?? "username" : "mkyong" }
????6. Find Records
??????????????
??????????????????????db.tablename.find??{???}?? ??
????6.1?г??????м????“???”??
> db.users.find()
{ "_id" : ObjectId("504f48ea17f6c778042c3c0a")?? "username" : "google"?? "password" : "google123" }
{ "_id" : ObjectId("504f45cd17f6c778042c3c07")?? "password" : "hello123"?? "username" : "mkyong" }
>db.users.find????
{ “_id”??OBJECTID??“504f48ea17f6c778042c3c0a????“?????”??“???”??“????”??“google123” }
{ “_id”??OBJECTID??“504f45cd17f6c778042c3c07” ????“????“??“hello123” ??“?????”????“mkyong”}
????6.2???????????????????“google”
> db.users.find({username:"google"})
{ "_id" : ObjectId("504f48ea17f6c778042c3c0a")?? "username" : "google"?? "password" : "google123" }
>db.users.find??{???????“???”}??
{ “_id”??OBJECTID??“504f48ea17f6c778042c3c0a????“?????”??“???”??“????”??“google123” }
????6.3 Find records where username’s length is less than or equal to 2
????6.3????????????username?????С??????2
????6.4? Find records where username field is existed.
????6.4????????username??δ????????
????db.users.find({username:{$exists : true}})
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11