In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Root@adela-vm:/opt/mongodb_simple# numactl-- interleave=all bin/mongod-f conf/mongod.conf
About to fork child process, waiting until server is ready for connections.
Forked process: 4904
Child process started successfully, parent exiting
Root@adela-vm:/opt/mongodb_simple#. / bin/mongo 127.0.0.1:12345
MongoDB shell version: 2.6.9
Connecting to: 127.0.0.1:12345/test
> show dbs / / shows several databases
Admin (empty)
Local 0.078GB
> use adela / / switch to adela database without prior definition
Switched to db adela
> show dbs / / adela database does not add content, so it is not realistic
Admin (empty)
Local 0.078GB
>
The tables in RDBMS correspond to the collection collections in mongoDB, and the inserts are in json format
Db. Collection name (table) .insert (json format)
Db.adela_collection.insert ({"x": 1})
Show all collections
> show collections
Adela_collection
System.indexes
Insert data
> db.adela_collection.insert ({ypur2})
WriteResult ({"nInserted": 1})
> db.adela_collection.find ()
{"_ id": ObjectId ("5514f09641daf13c28f7bdb7"), "x": 1}
{"_ id": ObjectId ("5514f12b41daf13c28f7bdb8"), "y": 2}
_ id is automatically assigned by the system and can be customized, but _ id cannot be repeated.
> db.adela_collection.insert ({aVera 1, recorder 1})
WriteResult ({"nInserted": 1})
> db.adela_collection.insert ({aVera 2, recorder 1})
WriteResult ({
"nInserted": 0
"writeError": {
"code": 11000
"errmsg": "insertDocument:: caused by:: 11000 E11000 duplicate key error index: adela.adela_collection.$_id_ dup key: {: 1.0}"
}
})
Query adela_collection full table
> db.adela_collection.find () / / No parameters are added
Query data with x = 1
> db.adela_collection.find ({XRV 1})
{"_ id": ObjectId ("5514f09641daf13c28f7bdb7"), "x": 1}
{"_ id": ObjectId ("5514f1d241daf13c28f7bdb9"), "x": 1}
Insert a batch of data in a loop
> for (iTun1teri db.adela_collection.find ()
{"_ id": ObjectId ("5514f09641daf13c28f7bdb7"), "x": 1}
{"_ id": ObjectId ("5514f12b41daf13c28f7bdb8"), "y": 2}
{"_ id": ObjectId ("5514f1d241daf13c28f7bdb9"), "x": 1}
{"_ id": 1, "a": 1}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe54"), "z": 1}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe55"), "z": 2}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe56"), "z": 3}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe57"), "z": 4}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe58"), "z": 5}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe59"), "z": 6}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5a"), "z": 7}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5b"), "z": 8}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5c"), "z": 9}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5d"), "z": 10}
Count count
> db.adela_collection.find () .count ()
fourteen
How many pieces of data did skip skip?
Limit limits how many pieces of data to return
Sort uses sorting
> db.adela_collection.find ()
{"_ id": ObjectId ("5514f09641daf13c28f7bdb7"), "x": 1}
{"_ id": ObjectId ("5514f12b41daf13c28f7bdb8"), "y": 2}
{"_ id": ObjectId ("5514f1d241daf13c28f7bdb9"), "x": 1}
{"_ id": 1, "a": 1}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe54"), "z": 1}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe55"), "z": 2}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe56"), "z": 3}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe57"), "z": 4}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe58"), "z": 5}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe59"), "z": 6}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5a"), "z": 7}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5b"), "z": 8}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5c"), "z": 9}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5d"), "z": 10}
> db.adela_collection.find () .skip (4)
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe54"), "z": 1}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe55"), "z": 2}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe56"), "z": 3}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe57"), "z": 4}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe58"), "z": 5}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe59"), "z": 6}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5a"), "z": 7}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5b"), "z": 8}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5c"), "z": 9}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe5d"), "z": 10}
> db.adela_collection.find () .skip (4) .limit (5)
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe54"), "z": 1}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe55"), "z": 2}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe56"), "z": 3}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe57"), "z": 4}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe58"), "z": 5}
> db.adela_collection.find () .skip (4) .limit (5) .sort ({zan1})
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe54"), "z": 1}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe55"), "z": 2}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe56"), "z": 3}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe57"), "z": 4}
{"_ id": ObjectId ("5514f5eca1b17c0bb936fe58"), "z": 5}
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.