In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Articles on the official website, comparing SQL and mongodb
Http://docs.mongodb.org/manual/reference/sql-comparison/
Db-displays the libraries currently in use
Show dbs-shows all libraries
Use db
Show collections-displays all tables in the current database
Db.testData.find ()-after selecting the database to operate on, db represents the current database object, testData represents the data table, and in mongo table is called collection. The find () function returns all records (record), and one record in mongo is called document. If the returned data records are very large and more than 20, only the first 20 records will be returned by default. Press "it" (iterate) to continue to display the following 20 records.
Db.testData.insert ()-insert data
Db.data.find ({"_ id": "3"})-- find the specified record
Db.testData.findOne ()
Db.testData.find (). Limit (3)
The language style of mongo's shell operation interaction window is javascript syntax, such as:
J = {name: "mongo"} k = {x: 3} db.testData.insert (j) db.testData.insert (k)
Indicates that two records are inserted.
{"_ id": ObjectId ("4c2209f9f3924d31102bd84a"), "name": "mongo"} {"_ id": ObjectId ("4c2209fef3924d31102bd84b"), "x": 3}
_ id is the only value in a table. If it is not specified, the default system assigns a record and a unique _ id, or you can specify _ id:
> testdate= {"_ id": "3", "isp_id": "1000314", "ip": "58.177.249.38", "request_url": "\ / bruce\ / laiye\ /", "referer": null, "_ ref": null, "user_agent": "Mozilla\ / 5.0( Macintosh; Intel Mac OS X 10.9) Rv:31.0) Gecko\ / 20100101 Firefox\ / 31.0 "} {" _ id ":" 3 "," isp_id ":" 1000314 "," ip ":" 58.177.249.38 "," request_url ":" / bruce/laiye/ "," referer ": null," _ ref ": null," user_agent ":" Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9) Rv:31.0) Gecko/20100101 Firefox/31.0 "} > db.data.insert (testdate) WriteResult ({" nInserted ": 1}) > db.data.find ({" _ id ":" 3 "}) {" _ id ":" 3 "," isp_id ":" 1000314 "," ip ":" 58.177.249.38 "," request_url ":" / bruce/laiye/ "," referer ": null "_ ref": null, "user_agent": "Mozilla/5.0 (Macintosh) Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Firefox/31.0 "}
Javascript syntax
/ / use the loop to quickly insert 25 records for (var I = 1; I
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: 301
*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.