In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Start shell: (the terminal should select linux when mainly using crt software, otherwise the Backspace key can sometimes go wrong.)
[root@saltstack mongodb] # mongo
> show dbs # View the database
Admin (empty)
Local 0.078GB
Modbtest 0.078GB
Myinfo (empty)
Test (empty)
Xiaoluo 0.078GB
> use dbtest # uses a database. If not, it will be created automatically.
Switched to db dbtest
# create a dictionary document, which is stored in key,value:
> test = {'id':1,'name':'xiaoming','job':'it'}
{"id": 1, "name": "xiaoming", "job": "it"}
> test
{"id": 1, "name": "xiaoming", "job": "it"}
# automatically create a table called dbtest, and then insert the dictionary test into it:
> db.dbtest.insert (test)
WriteResult ({"nInserted": 1})
# or you can insert data manually:
> db.dbtest.insert ({'id':2,'name':'xiaoli','job':'it'})
WriteResult ({"nInserted": 1})
# how to use find to view data:
> db.dbtest.find ()
{"_ id": ObjectId ("5513375e83aef55e0cc2d05c"), "id": 1, "name": "xiaoming", "job": "it"}
{"_ id": ObjectId ("5513379383aef55e0cc2d05d"), "id": 2, "name": "xiaoli", "job": "it"}
> show tables
Dbtest
System.indexes
# find according to the condition
> db.dbtest.find ({'id':1})
{"_ id": ObjectId ("5513375e83aef55e0cc2d05c"), "id": 1, "name": "xiaoming", "job": "it"}
# update the selection according to the conditions
> db.dbtest.update ({'id':2}, {' id':2,'name':'xiaoluo','job':'it'})
WriteResult ({"nMatched": 1, "nUpserted": 0, "nModified": 1})
> db.dbtest.find ({'id':2})
{"_ id": ObjectId ("5513379383aef55e0cc2d05d"), "id": 2, "name": "xiaoluo", "job": "it"}
>
# use the remove method to delete according to conditions. Delete id=2 's dictionary:
> db.dbtest.remove ({'id':2})
WriteResult ({"nRemoved": 1})
> db.dbtest.find ()
{"_ id": ObjectId ("5513375e83aef55e0cc2d05c"), "id": 1, "name": "xiaoming", "job": "it"}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.