In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.